#[repr(transparent)]
pub struct NixContext(HashSet<NixContextElement>);
Expand description

Nix context strings representation in Tvix. This tracks a set of different kinds of string dependencies that we can come across during manipulation of our language primitives, mostly strings. There’s some simple algebra of context strings and how they propagate w.r.t. primitive operations, e.g. concatenation, interpolation and other string operations.

Tuple Fields§

§0: HashSet<NixContextElement>

Implementations§

source§

impl NixContext

source

pub fn new() -> Self

Creates an empty context that can be populated and passed to form a contextful NixString, albeit if the context is concretly empty, the resulting NixString will be contextless.

source

pub(crate) fn is_empty(&self) -> bool

For internal consumers, we let people observe if the NixContext is actually empty or not to decide whether they want to skip the allocation of a full blown HashSet.

source

pub fn append(self, other: NixContextElement) -> Self

Consumes a new NixContextElement and add it if not already present in this context.

source

pub fn extend<T>(&mut self, iter: T)

Extends the existing context with more context elements.

source

pub fn mimic(&mut self, other: &NixString)

Copies from another NixString its context strings in this context.

source

pub fn iter_plain(&self) -> impl Iterator<Item = &str>

Iterates over “plain” context elements, e.g. sources imported in the store without more information, i.e. toFile or coerced imported paths. It yields paths to the store.

source

pub fn iter_derivation(&self) -> impl Iterator<Item = &str>

Iterates over “full derivations” context elements, e.g. something referring to their drvPath, i.e. their full sources and binary closure. It yields derivation paths.

source

pub fn iter_single_outputs(&self) -> impl Iterator<Item = (&str, &str)>

Iterates over “single” context elements, e.g. single derived paths, or also known as the single output of a given derivation. The first element of the tuple is the output name and the second element is the derivation path.

source

pub fn iter(&self) -> impl Iterator<Item = &NixContextElement>

Iterates over any element of the context.

source

pub fn to_owned_references(self) -> Vec<String>

Produces a list of owned references to this current context, no matter its type.

Trait Implementations§

source§

impl Clone for NixContext

source§

fn clone(&self) -> NixContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NixContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for NixContext

source§

fn default() -> NixContext

Returns the “default value” for a type. Read more
source§

impl<const N: usize> From<[NixContextElement; N]> for NixContext

source§

fn from(value: [NixContextElement; N]) -> Self

Converts to this type from the input type.
source§

impl From<HashSet<NixContextElement>> for NixContext

source§

fn from(value: HashSet<NixContextElement>) -> Self

Converts to this type from the input type.
source§

impl From<NixContextElement> for NixContext

source§

fn from(value: NixContextElement) -> Self

Converts to this type from the input type.
source§

impl IntoIterator for NixContext

§

type Item = NixContextElement

The type of the elements being iterated over.
§

type IntoIter = IntoIter<NixContextElement>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl Serialize for NixContext

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V