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.