Struct nuts_archive::Archive

source ·
pub struct Archive<B: Backend> { /* private fields */ }
Expand description

The archive.

Implementations§

source§

impl<B: Backend> Archive<B>

source

pub fn create( container: Container<B>, force: bool, ) -> ArchiveResult<Archive<B>, B>

Creates a new archive in container.

General initial information about the archive is stored in the user data of the container. This means the archive can be easily opened again the next time it is loaded. This means that no user data is currently allowed to be stored in the container, otherwise it could be overwritten. Existing user data can be overwritten if the force flag is set to true.

§Errors

If user data of the container could be overwritten, an Error::OverwriteUserdata error will be returned.

source

pub fn open(container: Container<B>) -> ArchiveResult<Archive<B>, B>

Opens an archive from container.

The initial information about the archive is loaded from the user data of the container.

§Errors

If no user data is stored in the container, an Error::InvalidUserdata(None) error is returned; if it does not contain valid archive information, an Error::InvalidUserdata(Some(...)) error is returned.

source

pub fn info(&self) -> Info

Fetches statistics/information from the archive.

source

pub fn first(&mut self) -> Option<ArchiveResult<Entry<'_, B>, B>>

Returns the first entry in the archive.

Next, you can use Entry::next() to traverse through the archive.

If the archive is empty, None is returned.

source

pub fn lookup<N: AsRef<str>>( &mut self, name: N, ) -> Option<ArchiveResult<Entry<'_, B>, B>>

Searches for an entry with the given name.

It scans the whole archive and returns the first entry which has the given name wrapped into a Some. If no such entry exists, None is returned.

source

pub fn append_file<N: AsRef<str>>(&mut self, name: N) -> FileBuilder<'_, B>

Appends a new file entry with the given name at the end of the archive.

The method returns a FileBuilder instance, where you are able to set some more properties for the new entry. Calling FileBuilder::build() will finally create the entry.

source

pub fn append_directory<N: AsRef<str>>( &mut self, name: N, ) -> DirectoryBuilder<'_, B>

Appends a new directory entry with the given name at the end of the archive.

The method returns a DirectoryBuilder instance, where you are able to set some more properties for the new entry. Calling DirectoryBuilder::build() will finally create the entry.

Appends a new symlink entry with the given name at the end of the archive.

The symlink points to the given target name.

The method returns a SymlinkBuilder instance, where you are able to set some more properties for the new entry. Calling SymlinkBuilder::build() will finally create the entry.

source

pub fn into_container(self) -> Container<B>

Consumes this Archive, returning the underlying Container.

Trait Implementations§

source§

impl<B: Backend> AsRef<Container<B>> for Archive<B>

source§

fn as_ref(&self) -> &Container<B>

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

§

impl<B> Freeze for Archive<B>
where <B as Backend>::Id: Freeze, B: Freeze,

§

impl<B> !RefUnwindSafe for Archive<B>

§

impl<B> !Send for Archive<B>

§

impl<B> !Sync for Archive<B>

§

impl<B> Unpin for Archive<B>
where <B as Backend>::Id: Unpin, B: Unpin,

§

impl<B> !UnwindSafe for Archive<B>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.