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(&mut self) -> Option<ArchiveResult<Entry<'_, B>, B>>
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.
sourcepub fn append_file<N: AsRef<str>>(&mut self, name: N) -> FileBuilder<'_, B>
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.
sourcepub fn append_directory<N: AsRef<str>>(
&mut self,
name: N,
) -> DirectoryBuilder<'_, B>
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.
sourcepub fn append_symlink<N: AsRef<str>, T: AsRef<str>>(
&mut self,
name: N,
target: T,
) -> SymlinkBuilder<'_, B>
pub fn append_symlink<N: AsRef<str>, T: AsRef<str>>( &mut self, name: N, target: T, ) -> SymlinkBuilder<'_, B>
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.
sourcepub fn into_container(self) -> Container<B>
pub fn into_container(self) -> Container<B>
Consumes this Archive, returning the underlying Container.