webc

Struct 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 version(&self) -> Version

Get the underlying webc version

source

pub fn manifest(&self) -> &Manifest

Get the Container’s manifest.

source

pub fn webc_hash(&self) -> Option<[u8; 32]>

Get the Container’s webc hash

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.

source

pub fn validate(&self) -> Result<(), Error>

Validates an [AbstractWebc]

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

Available on crate feature v2 only.
source§

fn from(value: OwnedReader) -> Self

Converts to this type from the input type.
source§

impl From<OwnedReader> for Container

Available on crate feature v3 only.
source§

fn from(value: OwnedReader) -> Self

Converts to this type from the input type.
source§

impl From<Package> for Container

Available on crate feature package only.
source§

fn from(value: Package) -> Self

Converts to this type from the input type.
source§

impl From<WebCMmap> for Container

Available on crate feature v1 only.
source§

fn from(value: WebCMmap) -> Self

Converts to this type from the input type.
source§

impl From<WebCOwned> for Container

Available on crate feature v1 only.
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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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> ToOwned for T
where T: Clone,

source§

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

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.