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>
Create a new decoder over the given Read
er.
Consider wrapping it in a std::io::BufReader
for
performance.
impl<R: Read> Decoder<R>
Create a new decoder over the given Read
er.
Consider wrapping it in a std::io::BufReader
for
performance.
pub fn new(reader: R) -> Result<Self, NarError>
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.
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.