Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions capnp/src/any_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#[cfg(feature = "alloc")]
use crate::capability::FromClientHook;
use crate::introspect::{Type, TypeVariant};
#[cfg(feature = "alloc")]
use crate::private::capability::{ClientHook, PipelineHook, PipelineOp};
use crate::private::layout::{PointerBuilder, PointerReader};
Expand Down Expand Up @@ -72,6 +73,21 @@
FromPointerReader::get_from_pointer(&self.reader, None)
}

#[inline]
pub fn get_as_dynamic(&self, ty: Type) -> Result<crate::dynamic_value::Reader<'a>> {
match ty.which() {
TypeVariant::List(element_type) => Ok(crate::dynamic_value::Reader::List(

Check warning on line 79 in capnp/src/any_pointer.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/any_pointer.rs#L77-L79

Added lines #L77 - L79 were not covered by tests
crate::dynamic_list::Reader {
reader: self
.reader
.get_list(element_type.expected_element_size(), None)?,
element_type,

Check warning on line 84 in capnp/src/any_pointer.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/any_pointer.rs#L81-L84

Added lines #L81 - L84 were not covered by tests
},
)),
_ => todo!(),

Check warning on line 87 in capnp/src/any_pointer.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/any_pointer.rs#L87

Added line #L87 was not covered by tests
}
}

Check warning on line 89 in capnp/src/any_pointer.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/any_pointer.rs#L89

Added line #L89 was not covered by tests

#[cfg(feature = "alloc")]
pub fn get_as_capability<T: FromClientHook>(&self) -> Result<T> {
Ok(FromClientHook::new(self.reader.get_capability()?))
Expand Down
Loading