pub struct Decoder<R: Read> { /* private fields */ }Expand description
Decoder that can extract the contents of NAR files.
Implementations§
Source§impl<R: Read> Decoder<R>
impl<R: Read> Decoder<R>
Sourcepub fn new(reader: R) -> Result<Self, NarError>
pub fn new(reader: R) -> Result<Self, NarError>
Create a new decoder over the given Reader.
Consider wrapping it in a std::io::BufReader for
performance.
§Errors
Returns an error if the reader does not contain a valid NAR header.
Sourcepub fn entries(&self) -> Result<Entries<'_, R>, NarError>
pub fn entries(&self) -> Result<Entries<'_, R>, NarError>
Construct an iterator over the entries in this archive.
You must consider each entry within an archive in sequence. If entries are processed out of sequence (from what the iterator returns), then the contents read for each entry may be corrupted.
§Errors
Returns an error if called on a decoder that has already been used.
Sourcepub fn unpack<P: AsRef<Path>>(&self, dst: P) -> Result<(), NarError>
pub fn unpack<P: AsRef<Path>>(&self, dst: P) -> Result<(), NarError>
Unpacks the contents of the NAR file to the given destination (which must not already exist).
This operation will not not write files outside of the path
specified by dst. Files in the archive which have a .. in
their path are skipped during the unpacking process.
No attempt is made to validate the targets of symlinks.
If the NAR file is invalid, this function returns an error.
For instance, this happens if an Entry’s parent doesn’t
exist or is not a directory.
§Errors
Returns an error if the destination already exists, the NAR is invalid, or an I/O error occurs during unpacking.