Struct Decoder

Source
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 Reader. Consider wrapping it in a std::io::BufReader for performance.

Source

pub fn new(reader: R) -> Result<Self, NarError>

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<R> !Freeze for Decoder<R>

§

impl<R> !RefUnwindSafe for Decoder<R>

§

impl<R> Send for Decoder<R>
where R: Send,

§

impl<R> !Sync for Decoder<R>

§

impl<R> Unpin for Decoder<R>
where R: Unpin,

§

impl<R> UnwindSafe for Decoder<R>
where R: UnwindSafe,

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

Source§

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

Source§

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.