pub struct Encoder<FS: FileSystem = NativeFileSystem> { /* private fields */ }Expand description
Encoder which can archive a given path as a NAR file.
The encoder will read the data to archive using its FileSystem
implementation. By default, it reads the host filesystem using
std::fs.
Implementations§
Source§impl Encoder<NativeFileSystem>
impl Encoder<NativeFileSystem>
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<Self, NarError>
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self, NarError>
Create a new encoder for file hierarchy at the given path using default filesystem implementation.
§Errors
Returns an error if the path is not valid UTF-8.
Sourcepub fn builder<P: AsRef<Path>>(path: P) -> EncoderBuilder<P>
pub fn builder<P: AsRef<Path>>(path: P) -> EncoderBuilder<P>
Create a builder for this encoder that can take additional options.
use nix_nar::{Encoder, NativeFileSystem};
let mut enc = Encoder::builder("./test-data/")
.internal_buffer_size(2048)
.filesystem(NativeFileSystem {})
.build().unwrap();
let mut nar = File::create("output2.nar")?;
io::copy(&mut enc, &mut nar)?;Trait Implementations§
Source§impl<FS: FileSystem> Read for Encoder<FS>
Read the encoded NAR file.
impl<FS: FileSystem> Read for Encoder<FS>
Read the encoded NAR file.
§Errors
Self::read will return underlying I/O errors returned by FileSystem.
It will also return an error if the data read from an archived
file is not the same length as declared by
FileSystem::metadata. The length from the metadata was already
written to the NAR output at this point, so it’s not possible to
recover and produce a valid archive.
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)