Skip to main content

Container

Struct Container 

Source
pub struct Container { /* private fields */ }
Expand description

An ASiC-E container held in memory.

Implementations§

Source§

impl Container

Source

pub fn new() -> Self

Create an empty container.

Source

pub fn data_files(&self) -> &[DataFile]

Data files in the container.

Source

pub fn signatures(&self) -> &[SignatureFile]

Signature documents in the container.

Source

pub fn warnings(&self) -> &[String]

Structural warnings collected when opening the container.

Source

pub fn add_file( &mut self, name: impl Into<String>, mime_type: impl Into<String>, content: Vec<u8>, ) -> Result<()>

Add a data file.

§Errors

If the name is not relative, a duplicate, or reserved.

Source

pub fn add_signature_xml(&mut self, xml: String) -> &SignatureFile

Append a signature document.

The entry name is assigned automatically as META-INF/signaturesN.xml, using the first free index N.

Source

pub fn open<R: Read + Seek>(reader: R) -> Result<Self>

Open a container from any seekable reader, using default OpenOptions.

Source

pub fn open_with<R: Read + Seek>(reader: R, opts: &OpenOptions) -> Result<Self>

Open a container from any seekable reader under an explicit policy.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Open a container from a byte buffer.

Source

pub fn from_bytes_with(bytes: &[u8], opts: &OpenOptions) -> Result<Self>

Open a container from a byte buffer under an explicit policy.

Source

pub fn open_file(path: impl AsRef<Path>) -> Result<Self>

Open a container file from disk.

Source

pub fn open_file_with( path: impl AsRef<Path>, opts: &OpenOptions, ) -> Result<Self>

Open a container file from disk under an explicit policy.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>>

Serialize the container to a byte buffer.

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<()>

Write the container to a file on disk.

Trait Implementations§

Source§

impl Debug for Container

Source§

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

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

impl Default for Container

Source§

fn default() -> Container

Returns the “default value” for a type. Read more

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

Source§

type Output = T

Should always be Self
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.