Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::ContentAddressMethod Struct Reference

#include <content-address.hh>

Public Types

enum struct  Raw { Flat , NixArchive , Git , Text }

Public Member Functions

bool operator== (const ContentAddressMethod &) const =default
auto operator<=> (const ContentAddressMethod &) const =default
 MAKE_WRAPPER_CONSTRUCTOR (ContentAddressMethod)
std::string_view render () const
std::string_view renderPrefix () const
std::string renderWithAlgo (HashAlgorithm ha) const
FileIngestionMethod getFileIngestionMethod () const
FileSerialisationMethod getFileSerialisationMethod () const

Static Public Member Functions

static ContentAddressMethod parse (std::string_view rawCaMethod)
static ContentAddressMethod parsePrefix (std::string_view &m)
static std::pair< ContentAddressMethod, HashAlgorithm > parseWithAlgo (std::string_view rawCaMethod)

Public Attributes

Raw raw

Detailed Description

An enumeration of all the ways we can content-address store objects.

Just the type of a content address. Combine with the hash itself, and we have a ContentAddress as defined below. Combine that, in turn, with info on references, and we have ContentAddressWithReferences, as defined further below.

Member Enumeration Documentation

◆ Raw

enum struct nix::ContentAddressMethod::Raw
strong
Enumerator
Flat 

Calculate a store path using the FileIngestionMethod::Flat hash of the file system objects, and references.

See store-object/content-address.md#method-flat in the manual.

NixArchive 

Calculate a store path using the FileIngestionMethod::NixArchive hash of the file system objects, and references.

See store-object/content-address.md#method-flat in the manual.

Git 

Calculate a store path using the FileIngestionMethod::Git hash of the file system objects, and references.

Part of ExperimentalFeature::GitHashing.

See store-object/content-address.md#method-git in the manual.

Text 

Calculate a store path using the FileIngestionMethod::Flat hash of the file system objects, and references, but in a different way than ContentAddressMethod::Raw::Flat.

See store-object/content-address.md#method-text in the manual.

Member Function Documentation

◆ getFileIngestionMethod()

FileIngestionMethod nix::ContentAddressMethod::getFileIngestionMethod ( ) const

Get the underlying way to content-address file system objects.

Different ways of hashing store objects may use the same method for hashing file systeme objects.

◆ getFileSerialisationMethod()

FileSerialisationMethod nix::ContentAddressMethod::getFileSerialisationMethod ( ) const

The FileSerialisationMethod that is recommended for this content addressing method. In some circumstances, other methods are also valid. Note that Git is mapped to NixArchive, even though it could represent a single file. There is no support for flat serialisation of merkle objects; and even if there were, it would be unable to represent executable files.

◆ parse()

ContentAddressMethod nix::ContentAddressMethod::parse ( std::string_view rawCaMethod)
static

Parse a content addressing method (name).

The inverse of render.

◆ parsePrefix()

ContentAddressMethod nix::ContentAddressMethod::parsePrefix ( std::string_view & m)
static

Parse the prefix tag which indicates how the files were ingested, with the fixed output case not prefixed for back compat.

Parameters
mA string that should begin with the prefix. On return, the remainder of the string after the prefix.

◆ parseWithAlgo()

std::pair< ContentAddressMethod, HashAlgorithm > nix::ContentAddressMethod::parseWithAlgo ( std::string_view rawCaMethod)
static

Parse a content addressing method and hash algorithm.

◆ render()

std::string_view nix::ContentAddressMethod::render ( ) const

Render a content addressing method (name).

The inverse of parse.

◆ renderPrefix()

std::string_view nix::ContentAddressMethod::renderPrefix ( ) const

Render the prefix tag which indicates how the files were ingested.

The rough inverse of parsePrefix().

◆ renderWithAlgo()

std::string nix::ContentAddressMethod::renderWithAlgo ( HashAlgorithm ha) const

Render a content addressing method and hash algorithm in a nicer way, prefixing both cases.

The rough inverse of parse().


The documentation for this struct was generated from the following files: