Skip to main content

Stream

Struct Stream 

Source
pub struct Stream {
    pub chunks: Vec<Chunk>,
}
Expand description

Represents the layout of a zstd:chunked file. You can reconstruct the original file contents by iterating over the chunks.

Fields§

§chunks: Vec<Chunk>

The chunks in the file.

Implementations§

Source§

impl Stream

Source

pub fn new_from_frames(manifest: &[u8], tarsplit: &[u8]) -> Result<Self>

Create the metadata structure from the compressed frames referred to by the ranges in the OCI layer descriptor annotations or the file footer.

§Errors

This function can fail if any of the metadata isn’t in the expected format (zstd-compressed JSON) or if there are missing mandatory fields or internal inconsistencies. In all cases, it indicates a corrupt zstd:chunked file (or a bug in the library).

Source

pub fn references(&self) -> impl Iterator<Item = &ContentReference>

Iterates over all of the references that need to be satisfied for this stream to be reconstructed. This might be useful to help prefetch the required items.

Source

pub fn write_to( &self, write: &mut impl Write, resolve_reference: impl Fn(&ContentReference) -> Result<Vec<u8>>, ) -> Result<()>

Writes the content of the stream to the given writer. The resolve_reference() function should return the decompressed data corresponding to the reference.

§Errors

This function can fail only in response to external errors: a failure of the resolve_reference() function or a failure to write to the writer.

Trait Implementations§

Source§

impl Debug for Stream

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.