Skip to main content

StreamWriter

Struct StreamWriter 

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

Source

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.

Source

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.

Source

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.

Source

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.

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.

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.

Source

pub fn finish(self) -> Result<WriteArtifact, WriteError>

Materialise the tree and assemble the image.

§Errors

WriteError::Io on any writer-pipeline error.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.