Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to retrieve ReaderSegments object from reader objects #526

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
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
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 @@
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()
}

Check warning on line 305 in capnp/src/message.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/message.rs#L303-L305

Added lines #L303 - L305 were not covered by tests
}

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

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

Check warning on line 342 in capnp/src/message.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/message.rs#L340-L342

Added lines #L340 - L342 were not covered by tests
}

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 @@
pub fn into_segments(self) -> S {
self.segments
}

pub(crate) fn get_segments(&self) -> &S {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this one should be public or not so i've kept it private for now.

&self.segments
}

Check warning on line 88 in capnp/src/private/arena.rs

View check run for this annotation

Codecov / codecov/patch

capnp/src/private/arena.rs#L86-L88

Added lines #L86 - L88 were not covered by tests
}

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