Struct nuts_archive::Archive
source · pub struct Archive<B: Backend> { /* private fields */ }Expand description
The archive.
Implementations§
source§impl<B: Backend> Archive<B>
impl<B: Backend> Archive<B>
sourcepub fn create(
container: Container<B>,
force: bool
) -> ArchiveResult<Archive<B>, B>
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.
sourcepub fn open(container: Container<B>) -> ArchiveResult<Archive<B>, B>
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.
sourcepub fn first<'a>(&'a mut self) -> Option<ArchiveResult<Entry<'a, B>, B>>
pub fn first<'a>(&'a mut self) -> Option<ArchiveResult<Entry<'a, 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.
sourcepub fn append<'a, N: AsRef<str>>(&'a mut self, name: N) -> EntryBuilder<'a, B>
pub fn append<'a, N: AsRef<str>>(&'a mut self, name: N) -> EntryBuilder<'a, B>
Appends a new entry with the given name at the end of the archive.
The method returns an EntryBuilder instance, where you are able to
set some more properties for the new entry. Calling
EntryBuilder::build() will finally create the entry.
sourcepub fn into_container(self) -> Container<B>
pub fn into_container(self) -> Container<B>
Consumes this Archive, returning the underlying Container.