Skip to content

Commit

Permalink
Add remaining method to ZBytesReader (#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets authored Jun 19, 2024
1 parent 86490c1 commit e543dce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion zenoh/src/api/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use uhlc::Timestamp;
use unwrap_infallible::UnwrapInfallible;
use zenoh_buffers::{
buffer::{Buffer, SplitBuffer},
reader::HasReader,
reader::{HasReader, Reader},
writer::HasWriter,
ZBuf, ZBufReader, ZBufWriter, ZSlice,
};
Expand Down Expand Up @@ -185,6 +185,16 @@ impl ZBytes {
pub struct ZBytesReader<'a>(ZBufReader<'a>);

impl ZBytesReader<'_> {
/// Returns the number of bytes that can still be read
pub fn remaining(&self) -> usize {
self.0.remaining()
}

/// Returns true if no more bytes can be read
pub fn is_empty(&self) -> bool {
self.remaining() == 0
}

/// Deserialize an object of type `T` from a [`Value`] using the [`ZSerde`].
pub fn deserialize<T>(&mut self) -> ZResult<T>
where
Expand Down

0 comments on commit e543dce

Please sign in to comment.