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_disk(path: impl AsRef<Path>) -> Result<Self, ContainerError>
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.
sourcepub fn from_bytes(bytes: impl Into<Bytes>) -> Result<Self, ContainerError>
pub fn from_bytes(bytes: impl Into<Bytes>) -> Result<Self, ContainerError>
Load a Container
from bytes in memory.
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
)