pub struct SplitdirfdstreamWriter<W> { /* private fields */ }Expand description
Writer for building a splitdirfdstream.
Encodes inline data and dirfd-relative file references into the splitdirfdstream binary format.
§Example
use composefs_splitdirfdstream::SplitdirfdstreamWriter;
let mut buffer = Vec::new();
let mut writer = SplitdirfdstreamWriter::new(&mut buffer);
writer.write_metadata(b"hello").unwrap();
writer.write_file_backed_data(0, 42, b"objects/abc123").unwrap();
let _buf = writer.finish().unwrap();Implementations§
Source§impl<W: Write> SplitdirfdstreamWriter<W>
impl<W: Write> SplitdirfdstreamWriter<W>
Sourcepub fn write_metadata(&mut self, data: &[u8]) -> Result<()>
pub fn write_metadata(&mut self, data: &[u8]) -> Result<()>
Write an inline chunk containing data.
Empty slices are silently ignored (no bytes are written).
§Errors
Returns Error::InlineTooLarge if data.len() exceeds
MAX_INLINE_CHUNK_SIZE, or propagates I/O errors from the
underlying writer.
Sourcepub fn write_inline_data(&mut self, data: &[u8]) -> Result<()>
pub fn write_inline_data(&mut self, data: &[u8]) -> Result<()>
Write an InlineData chunk carrying data bytes
of file content transported inline.
Unlike write_metadata, a zero-length slice IS
written (a zero-byte non-world-readable file must still round-trip).
§Errors
Returns Error::InlineTooLarge if data.len() exceeds
MAX_INLINE_CHUNK_SIZE, or propagates I/O errors from the underlying
writer.
Sourcepub fn write_file_backed_data(
&mut self,
dirfd_index: u32,
length: u64,
filename: &[u8],
) -> Result<()>
pub fn write_file_backed_data( &mut self, dirfd_index: u32, length: u64, filename: &[u8], ) -> Result<()>
Write a FileBackedData chunk referencing a
file by dirfd index and relative filename.
The consumer will open filename beneath dirfds[dirfd_index] and
read exactly length bytes from offset 0.
filename is validated by validate_filename before writing.
§Errors
Returns any Error produced by validate_filename, or propagates
I/O errors from the underlying writer.