pub struct Node<'a, W: Write> {
writer: &'a mut W,
}
Expand description
Single node in a NAR file.
A NAR can be thought of as a tree of nodes represented by this type. Each node can be a file, a symlink or a directory containing other nodes.
Fields§
§writer: &'a mut W
Implementations§
source§impl<'a, W: Write> Node<'a, W>
impl<'a, W: Write> Node<'a, W>
fn write(&mut self, data: &[u8]) -> Result<()>
fn pad(&mut self, n: u64) -> Result<()>
sourcepub fn file(
self,
executable: bool,
size: u64,
reader: &mut dyn BufRead,
) -> Result<()>
pub fn file( self, executable: bool, size: u64, reader: &mut dyn BufRead, ) -> Result<()>
Make this node a single file.
sourcepub fn file_manual_write(
self,
executable: bool,
size: u64,
) -> Result<(&'a mut W, FileManualWrite)>
pub fn file_manual_write( self, executable: bool, size: u64, ) -> Result<(&'a mut W, FileManualWrite)>
Make this node a single file but let the user handle the writing of the file contents. The user gets access to a writer to write the file contents to, plus a struct they must invoke a function on to finish writing the NAR file.
It is the caller’s responsibility to write the correct number of bytes to the writer and
invoke FileManualWrite::close
, or invalid archives will be produced silently.
let contents = "Hello world\n".as_bytes();
let size = contents.len() as u64;
let executable = false;
let (writer, skip) = nar
.file_manual_write(executable, size)?;
// Write the contents
writer.write_all(&contents)?;
// Close the file node
skip.close(writer)?;
Auto Trait Implementations§
impl<'a, W> Freeze for Node<'a, W>
impl<'a, W> RefUnwindSafe for Node<'a, W>where
W: RefUnwindSafe,
impl<'a, W> Send for Node<'a, W>where
W: Send,
impl<'a, W> Sync for Node<'a, W>where
W: Sync,
impl<'a, W> Unpin for Node<'a, W>
impl<'a, W> !UnwindSafe for Node<'a, W>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more