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
impl Container
Sourcepub fn from_bytes_and_version(
bytes: Bytes,
version: Version,
) -> Result<Self, ContainerError>
pub fn from_bytes_and_version( bytes: Bytes, version: Version, ) -> Result<Self, ContainerError>
Creates a container from a webc content with a specific version
Sourcepub fn atoms(&self) -> BTreeMap<String, OwnedBuffer>
pub fn atoms(&self) -> BTreeMap<String, OwnedBuffer>
Get all atoms stored in the container as a map.
Sourcepub fn get_atom(&self, name: &str) -> Option<OwnedBuffer>
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.
Sourcepub fn get_volume(&self, name: &str) -> Option<Volume>
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.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: 'static,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: 'static,
Downcast the Container
a concrete implementation.
Sourcepub fn unpack(
&self,
out_dir: &Path,
overwrite: bool,
) -> Result<(), ContainerError>
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 From<OwnedReader> for Container
Available on crate feature v2
only.
impl From<OwnedReader> for Container
v2
only.Source§fn from(value: OwnedReader) -> Self
fn from(value: OwnedReader) -> Self
Source§impl From<OwnedReader> for Container
Available on crate feature v3
only.
impl From<OwnedReader> for Container
v3
only.Source§fn from(value: OwnedReader) -> Self
fn from(value: OwnedReader) -> Self
Auto Trait Implementations§
impl Freeze for Container
impl !RefUnwindSafe for Container
impl Send for Container
impl Sync for Container
impl Unpin for Container
impl !UnwindSafe for Container
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)