Add the 'get()' method
Also some type fixes
@@ -25,7 +25,7 @@ use any_pointer;
use private::arena::{BuilderArenaImpl, ReaderArenaImpl, BuilderArena, ReaderArena};
use private::layout;
use private::units::BYTES_PER_WORD;
-use traits::{FromPointerReader, FromPointerBuilder, SetPointerBuilder};
+use traits::{FromPointerReader, FromPointerBuilder, SetPointerBuilder, Owned};
use {OutputSegments, Result, Word};
/// Options controlling how data is read.
@@ -180,21 +180,25 @@ impl <S> Reader<S> where S: ReaderSegments {
/// A reader object that owns the underlying data in the message
pub struct OwnedReader<S, T>
where S: ReaderSegments,
- T: for<'a> ::capnp::traits::Owned<'a> {
+ T: for<'a> Owned<'a> {
marker: ::std::marker::PhantomData<T>,
- message: ::capnp::message::Reader<S>,
+ message: Reader<S>,
}
impl <S, T> OwnedReader<S, T>
where S: ReaderSegments,
- T : for<'a> ::capnp::traits::Owned<'a> {
+ T : for<'a> Owned<'a> {
- pub fn new(message: ::capnp::message::Reader<::capnp::serialize::OwnedSegments>) -> Self {
+ pub fn new(message: Reader<S>) -> Self {
OwnedReader {
marker: ::std::marker::PhantomData,
message: message,
}
}
+
+ pub fn get<'a> (&'a self) -> Result<<T as Owned<'a>>::Reader> {
+ self.message.get_root()
+ }
}
/// An object that allocates memory for a Cap'n Proto message as it is being built.
