Module async

Module async 

Source
Available on crate feature async only.
Expand description

Implements an interface for writing the Nix archive format (NAR).

NAR files (and their hashed representations) are used in C++ Nix for addressing fixed-output derivations and a variety of other things.

NAR files can be output to any type that implements AsyncWrite, and content can be read from any type that implementes AsyncBufRead.

Writing a single file might look like this:


// Output location to write the NAR to.
let mut sink: Vec<u8> = Vec::new();

// Instantiate writer for this output location.
let mut nar = nix_compat::nar::writer::r#async::open(&mut sink).await?;

// Acquire metadata for the single file to output, and pass it in a
// `BufRead`-implementing type.

let executable = false;
let size = some_file.len() as u64;
let mut reader = BufReader::new(some_file.as_slice());
nar.file(executable, size, &mut reader).await?;

Structs§

Directory
Content of a NAR node that represents a directory.
Node
Single node in a NAR file.

Functions§

into_name 🔒
open
Create a new NAR, writing the output to the specified writer.

Type Aliases§

Name 🔒 Debug-assertions enabled
Writer
Convenience type alias for types implementing AsyncWrite.