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
impl Stream
Sourcepub fn new_from_frames(manifest: &[u8], tarsplit: &[u8]) -> Result<Self>
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).
Sourcepub fn references(&self) -> impl Iterator<Item = &ContentReference>
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.
Sourcepub fn write_to(
&self,
write: &mut impl Write,
resolve_reference: impl Fn(&ContentReference) -> Result<Vec<u8>>,
) -> Result<()>
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.