Skip to main content

SplitdirfdstreamReader

Struct SplitdirfdstreamReader 

Source
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>

Source

pub fn new(reader: R) -> Self

Create a new reader wrapping reader.

Source

pub fn into_inner(self) -> R

Consume this reader, returning the underlying Read impl.

Source

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

Trait Implementations§

Source§

impl<R: Debug> Debug for SplitdirfdstreamReader<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.