diff --git a/capnp/src/any_pointer.rs b/capnp/src/any_pointer.rs index f42979331..11b985a82 100644 --- a/capnp/src/any_pointer.rs +++ b/capnp/src/any_pointer.rs @@ -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}; @@ -72,6 +73,21 @@ impl<'a> Reader<'a> { FromPointerReader::get_from_pointer(&self.reader, None) } + #[inline] + pub fn get_as_dynamic(&self, ty: Type) -> Result> { + match ty.which() { + TypeVariant::List(element_type) => Ok(crate::dynamic_value::Reader::List( + crate::dynamic_list::Reader { + reader: self + .reader + .get_list(element_type.expected_element_size(), None)?, + element_type, + }, + )), + _ => todo!(), + } + } + #[cfg(feature = "alloc")] pub fn get_as_capability(&self) -> Result { Ok(FromClientHook::new(self.reader.get_capability()?))