pub struct StreamWriter<'a> { /* private fields */ }Expand description
Build one .lim image from a sequence of named streams.
Create with StreamWriter::new, add entries in any order
(add_file, add_dir, add_symlink), then finish to
assemble the artifact. Names are /-separated image-relative
paths; parent directories are materialised implicitly, or
explicitly via add_dir to control mtimes and empty
directories.
§Errors
WriteError::Io on reader failure, invalid names, conflicting
paths, or any writer-pipeline error.
Implementations§
Source§impl<'a> StreamWriter<'a>
impl<'a> StreamWriter<'a>
Sourcepub fn new(config: &'a WriteConfig) -> Result<Self, WriteError>
pub fn new(config: &'a WriteConfig) -> Result<Self, WriteError>
Start a stream write under config.
§Errors
WriteError::Io if the config’s codec registry or chunking
parameters are invalid.
Sourcepub fn add_file(
&mut self,
name: &str,
meta: EntryMeta,
xattrs: &[(String, Vec<u8>)],
reader: &mut dyn Read,
) -> Result<(), WriteError>
pub fn add_file( &mut self, name: &str, meta: EntryMeta, xattrs: &[(String, Vec<u8>)], reader: &mut dyn Read, ) -> Result<(), WriteError>
Add a regular file at name, streaming reader through the
chunker. Small entries (within the config’s inline
threshold) are stored inline, matching the directory writer.
§Errors
WriteError::Io if the name is invalid or conflicts with
an existing entry, or the reader fails.
Sourcepub fn stage_file(
&mut self,
name: &str,
meta: EntryMeta,
xattrs: &[(String, Vec<u8>)],
data: &'a [u8],
) -> Result<(), WriteError>
pub fn stage_file( &mut self, name: &str, meta: EntryMeta, xattrs: &[(String, Vec<u8>)], data: &'a [u8], ) -> Result<(), WriteError>
Stage a random-access entry for parallel packing: like
[add_file], but the data is an in-memory slice (e.g. an
mmap’d archive entry) whose byte range is already known, so
chunk/hash/compress work is deferred to [finish], which
fans the staged set across rayon workers and merges the
results serially in stage order. Same entries, same order →
byte-identical image to the serial add_file path.
The borrow of data must outlive the writer.
§Errors
WriteError::Io if the name is invalid or conflicts with
an existing entry.
Sourcepub fn add_dir(&mut self, name: &str, meta: EntryMeta) -> Result<(), WriteError>
pub fn add_dir(&mut self, name: &str, meta: EntryMeta) -> Result<(), WriteError>
Add (or declare) a directory at name with the given
identity. Implicit parents created by nested entries keep
mtime 0 / root; calling this on an existing implicit
directory stamps it.
§Errors
WriteError::Io if the name is invalid or conflicts with
a non-directory entry.
Sourcepub fn add_hardlink(
&mut self,
name: &str,
target: &str,
) -> Result<(), WriteError>
pub fn add_hardlink( &mut self, name: &str, target: &str, ) -> Result<(), WriteError>
Add a hardlink at name referencing the file already added
(by any path method) at target — both names share one
inode, and the emitted inode carries the real nlink. The
target must exist in the tree and be a regular file.
§Errors
WriteError::Io if name is invalid or conflicting, the
target is missing, or the target is not a regular file.
Sourcepub fn add_symlink(
&mut self,
name: &str,
target: &str,
meta: EntryMeta,
) -> Result<(), WriteError>
pub fn add_symlink( &mut self, name: &str, target: &str, meta: EntryMeta, ) -> Result<(), WriteError>
Add a symbolic link at name pointing at target (stored
raw, exactly as given).
§Errors
WriteError::Io if the name is invalid or conflicts with
an existing entry.
Sourcepub fn finish(self) -> Result<WriteArtifact, WriteError>
pub fn finish(self) -> Result<WriteArtifact, WriteError>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for StreamWriter<'a>
impl<'a> !UnwindSafe for StreamWriter<'a>
impl<'a> Freeze for StreamWriter<'a>
impl<'a> Send for StreamWriter<'a>
impl<'a> Sync for StreamWriter<'a>
impl<'a> Unpin for StreamWriter<'a>
impl<'a> UnsafeUnpin for StreamWriter<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more