Greetings,
I'd like to initialize a list of list of list of texts
The Capnproto contract:
@0xf3fc3585f75860e4;
struct ListListListText {
texts @0 :List(List(List(Text)));
}
The data structure I want to insert into the contract:
let mock_commands =
vec![ // a file
vec![ // lines
vec![ // pipe symbol contents | |
vec!["ls1","-l","-a"], // command + args
vec!["ls1","-l","-a"],
],
vec![
vec!["ls1","-l","-a"],
vec!["ls1","-l","-a"],
],
],
vec![
vec![
vec!["ls1","-l","-a"],
vec!["ls1","-l","-a"],
],
vec![
vec!["ls1","-l","-a"],
vec!["ls1","-l","-a"],
],
],
];
The insertion fails:
let ip = out_ip.init_root::<list_list_list_text::Builder>();
let mut lines_count: u32 = 0;
for lines in &mock_commands {
let mut line_count: u32 = 0;
let ip_lines = ip.init_texts(lines.len() as u32);
for line in lines {
let mut pipe_section_count: u32 = 0;
let ip_line = ip_lines.borrow().set(line_count,
ip_lines.init_texts(lines.len() as u32));
for pipe_section in line {
//let ip_pipe_section = ip_line.init_texts(pipe_section.len()
as u32);
for argument in pipe_section {
//println!("{:?}", argument );
}
pipe_section_count += 1;
}
line_count += 1;
}
lines_count += 1;
}
with:
src/lib.rs:62:53: 62:56 error: no method named `set` found for type
`capnp::list_list::Builder<'_,
capnp::list_list::Owned<capnp::text_list::Owned>>` in the current scope
src/lib.rs:62 let ip_line =
ip_lines.borrow().set(line_count, ip_lines.init_texts(lines.len() as u32));
^~~
src/lib.rs:14:1: 125:2 note: in this expansion of component! (defined in
<rustfbp macros>)
src/lib.rs:62:78: 62:88 error: no method named `init_texts` found for type
`capnp::list_list::Builder<'_,
capnp::list_list::Owned<capnp::text_list::Owned>>` in the current scope
src/lib.rs:62 let ip_line =
ip_lines.borrow().set(line_count, ip_lines.init_texts(lines.len() as u32));
Now I've seen other examples (in python?) whereby people use something like
this:
proto.myList = [[1], [2,3], [4,5,6]] # to insert a list of lists
In Rust, how do I quickly and succinctly create a list of list of list of
texts?
/sjm
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.