pub struct SplitdirfdstreamReader<R> { /* private fields */ }Expand description
Reader for parsing a splitdirfdstream.
Yields Chunk values by parsing the binary format. The internal buffer
is reused across calls so that only one chunk’s data is live at a time.
§Example
use composefs_splitdirfdstream::{SplitdirfdstreamReader, Chunk};
// Manually constructed stream: Metadata "hello"
// Format: [0x00][5u32 LE][b"hello"]
let mut data = Vec::new();
data.push(0x00u8);
data.extend_from_slice(&5u32.to_le_bytes());
data.extend_from_slice(b"hello");
let mut reader = SplitdirfdstreamReader::new(data.as_slice());
assert_eq!(reader.next_chunk().unwrap(), Some(Chunk::Metadata(b"hello")));
assert_eq!(reader.next_chunk().unwrap(), None);Implementations§
Source§impl<R: Read> SplitdirfdstreamReader<R>
impl<R: Read> SplitdirfdstreamReader<R>
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consume this reader, returning the underlying Read impl.
Sourcepub fn next_chunk(&mut self) -> Result<Option<Chunk<'_>>>
pub fn next_chunk(&mut self) -> Result<Option<Chunk<'_>>>
Return the next chunk from the stream, or None at a clean EOF.
A clean EOF is one where zero bytes have been consumed from the current
type byte. Any partial read (0 < n < expected) is Error::Truncated.
The returned Chunk::FileBackedData contains the raw filename bytes
without any validation — callers that use filename directly must
call validate_filename themselves, or use reconstruct which does
it internally via open_beneath.
§Errors
Error::Truncated— stream ended mid-chunkError::InlineTooLarge— Metadata or InlineData body size exceedsMAX_INLINE_CHUNK_SIZEError::FilenameTooLong— filename length exceedsMAX_FILENAME_LENError::UnknownChunkType— unrecognised type byteError::Io— underlying I/O error
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for SplitdirfdstreamReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for SplitdirfdstreamReader<R>where
R: RefUnwindSafe,
impl<R> Send for SplitdirfdstreamReader<R>where
R: Send,
impl<R> Sync for SplitdirfdstreamReader<R>where
R: Sync,
impl<R> Unpin for SplitdirfdstreamReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for SplitdirfdstreamReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for SplitdirfdstreamReader<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more