Skip to content

Commit

Permalink
Allow to retrieve ReaderSegments object from reader objects
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema authored and dwrensha committed Oct 22, 2024
1 parent 861052d commit f97060c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions capnp/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ where
pub fn size_in_words(&self) -> usize {
self.arena.size_in_words()
}

/// Retrieves the underlying [`ReaderSegments`] object.
pub fn get_segments(&self) -> &S {
self.arena.get_segments()
}
}

/// A message reader whose value is known to be of type `T`.
Expand Down Expand Up @@ -330,6 +335,11 @@ where
pub fn into_inner(self) -> Reader<S> {
self.message
}

/// Retrieves the underlying [`ReaderSegments`] object.
pub fn get_segments(&self) -> &S {
self.message.get_segments()
}
}

impl<S, T> From<Reader<S>> for TypedReader<S, T>
Expand Down
4 changes: 4 additions & 0 deletions capnp/src/private/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ where
pub fn into_segments(self) -> S {
self.segments
}

pub(crate) fn get_segments(&self) -> &S {
&self.segments
}
}

impl<S> ReaderArena for ReaderArenaImpl<S>
Expand Down

0 comments on commit f97060c

Please sign in to comment.