Struct webc::Container

source ·
pub struct Container { /* private fields */ }
Expand description

A version-agnostic read-only WEBC container.

A Container provides a high-level interface for reading and manipulating WEBC container files. It supports multiple versions of WEBC container formats and abstracts the underlying differences between them.

Implementations§

source§

impl Container

source

pub fn from_disk(path: impl AsRef<Path>) -> Result<Self, ContainerError>

Load a Container from disk.

Where possible, this will try to use a memory-mapped implementation to reduce memory usage.

source

pub fn from_bytes(bytes: impl Into<Bytes>) -> Result<Self, ContainerError>

Load a Container from bytes in memory.

source

pub fn manifest(&self) -> &Manifest

Get the Container’s manifest.

source

pub fn atoms(&self) -> BTreeMap<String, OwnedBuffer>

Get all atoms stored in the container as a map.

source

pub fn get_atom(&self, name: &str) -> Option<OwnedBuffer>

Get an atom with the given name.

Returns None if the atom does not exist in the container.

This operation is pretty cheap, typically just a dictionary lookup followed by reference count bump and some index math.

source

pub fn volumes(&self) -> BTreeMap<String, Volume>

Get all volumes stored in the container.

source

pub fn get_volume(&self, name: &str) -> Option<Volume>

Get a volume with the given name.

Returns None if the volume does not exist in the container.

source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: 'static,

Downcast the Container a concrete implementation.

source

pub fn downcast<T>(self) -> Result<Arc<T>, Self>
where T: 'static,

Downcast the Container a concrete implementation, returning the original Container if the cast fails.

source

pub fn unpack( &self, out_dir: &Path, overwrite: bool ) -> Result<(), ContainerError>

Unpack the container into a directory.

This will create a directory at out_dir and populate it with the the contents of each volume and the manifest.

If the output directory already exists and is not empty, the operation will fail, unless overwrite is set to true.

Trait Implementations§

source§

impl Clone for Container

source§

fn clone(&self) -> Container

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Container

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<OwnedReader> for Container

source§

fn from(value: OwnedReader) -> Self

Converts to this type from the input type.
source§

impl From<Package> for Container

source§

fn from(value: Package) -> Self

Converts to this type from the input type.
source§

impl From<WebCMmap> for Container

source§

fn from(value: WebCMmap) -> Self

Converts to this type from the input type.
source§

impl From<WebCOwned> for Container

source§

fn from(value: WebCOwned) -> Self

Converts to this type from the input type.

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.