Enum tvix_eval::Value

source ·
pub enum Value {
Show 17 variants Null, Bool(bool), Integer(i64), Float(f64), String(NixString), Path(Box<PathBuf>), Attrs(Box<NixAttrs>), List(NixList), Closure(Rc<Closure>), Builtin(Builtin), Thunk(Thunk), AttrNotFound, Blueprint(Rc<Lambda>), DeferredUpvalue(StackIdx), UnresolvedPath(Box<PathBuf>), FinaliseRequest(bool), Catchable(Box<CatchableErrorKind>),
}

Variants§

§

Null

§

Bool(bool)

§

Integer(i64)

§

Float(f64)

§

String(NixString)

§

Path(Box<PathBuf>)

§

Attrs(Box<NixAttrs>)

§

List(NixList)

§

Closure(Rc<Closure>)

§

Builtin(Builtin)

§

Thunk(Thunk)

§

AttrNotFound

§

Blueprint(Rc<Lambda>)

§

DeferredUpvalue(StackIdx)

§

UnresolvedPath(Box<PathBuf>)

§

FinaliseRequest(bool)

§

Catchable(Box<CatchableErrorKind>)

Implementations§

source§

impl Value

source

pub async fn into_contextful_json( self, co: &GenCo, ) -> Result<(Json, NixContext), ErrorKind>

Transforms the structure into a JSON and accumulate all encountered context in the second’s element of the return type.

source§

impl Value

source

pub fn attrs(attrs: NixAttrs) -> Self

Construct a Value::Attrs from a NixAttrs.

source

pub(crate) async fn deep_force( self, co: GenCo, span: Span, ) -> Result<Value, ErrorKind>

Deeply forces a value, traversing e.g. lists and attribute sets and forcing their contents, too.

This is a generator function.

source

async fn deep_force_( myself: Value, co: GenCo, span: Span, ) -> Result<Option<Value>, ErrorKind>

Returns Some(v) or None to indicate the returned value is myself

source

pub async fn coerce_to_string( self, co: GenCo, kind: CoercionKind, span: Span, ) -> Result<Value, ErrorKind>

source

pub async fn coerce_to_string_( self, co: &GenCo, kind: CoercionKind, span: Span, ) -> Result<Value, ErrorKind>

Coerce a Value to a string. See CoercionKind for a rundown of what input types are accepted under what circumstances.

source

pub(crate) async fn nix_eq_owned_genco( self, other: Value, co: GenCo, ptr_eq: PointerEquality, span: Span, ) -> Result<Value, ErrorKind>

source

pub(crate) async fn nix_eq( self, other: Value, co: &GenCo, ptr_eq: PointerEquality, span: Span, ) -> Result<Value, ErrorKind>

Compare two Nix values for equality, forcing nested parts of the structure as needed.

This comparison needs to be invoked for nested values (e.g. in lists and attribute sets) as well, which is done by suspending and asking the VM to perform the nested comparison.

The top_level parameter controls whether this invocation is the top-level comparison, or a nested value comparison. See //tvix/docs/value-pointer-equality.md

source

pub fn type_of(&self) -> &'static str

source

pub fn as_bool(&self) -> Result<bool, ErrorKind>

source

pub fn as_int(&self) -> Result<i64, ErrorKind>

source

pub fn as_float(&self) -> Result<f64, ErrorKind>

source

pub fn to_str(&self) -> Result<NixString, ErrorKind>

Cast the current value into a context-less string. If you wanted to cast it into a potentially contextful string, you have to explicitly use to_contextful_str. Contextful strings are special, they should not be obtained everytime you want a string.

source

pub fn to_contextful_str(&self) -> Result<NixString, ErrorKind>

source

pub fn to_path(&self) -> Result<Box<PathBuf>, ErrorKind>

source

pub fn to_attrs(&self) -> Result<Box<NixAttrs>, ErrorKind>

source

pub fn to_list(&self) -> Result<NixList, ErrorKind>

source

pub fn as_closure(&self) -> Result<Rc<Closure>, ErrorKind>

source

pub fn as_list_mut(&mut self) -> Result<&mut NixList, ErrorKind>

source

pub fn is_path(&self) -> bool

source

pub fn is_number(&self) -> bool

source

pub fn is_bool(&self) -> bool

source

pub fn is_attrs(&self) -> bool

source

pub fn is_catchable(&self) -> bool

source

pub fn is_thunk(&self) -> bool

Returns true if the value is a Thunk.

source

pub async fn nix_cmp_ordering( self, other: Self, co: GenCo, span: Span, ) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind>

Compare self against other using (fallible) Nix ordering semantics.

The function is intended to be used from within other generator functions or gen! blocks.

source

async fn nix_cmp_ordering_( myself: Self, other: Self, co: GenCo, span: Span, ) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind>

source

pub async fn force(self, co: &GenCo, span: Span) -> Result<Value, ErrorKind>

source

pub async fn force_owned_genco( self, co: GenCo, span: Span, ) -> Result<Value, ErrorKind>

source

pub fn explain(&self) -> String

Explain a value in a human-readable way, e.g. by presenting the docstrings of functions if present.

source

pub fn suspended_native_thunk( native: Box<dyn Fn() -> Result<Value, ErrorKind>>, ) -> Self

Constructs a thunk that will be evaluated lazily at runtime. This lets users of Tvix implement their own lazy builtins and so on.

Trait Implementations§

source§

impl Arbitrary for Value

source§

type Parameters = Parameters

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
source§

type Strategy = BoxedStrategy<Value>

The type of Strategy used to generate values of type Self.
source§

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
source§

impl Clone for Value

source§

fn clone(&self) -> Value

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 Value

source§

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

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

impl<'de> Deserialize<'de> for Value

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Value

source§

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

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

impl From<CatchableErrorKind> for Value

source§

fn from(c: CatchableErrorKind) -> Value

Converts to this type from the input type.
source§

impl From<PathBuf> for Value

source§

fn from(path: PathBuf) -> Self

Converts to this type from the input type.
source§

impl<V> From<Result<V, CatchableErrorKind>> for Value
where Value: From<V>,

source§

fn from(v: Result<V, CatchableErrorKind>) -> Value

Converts to this type from the input type.
source§

impl<T> From<T> for Value
where T: Into<NixString>,

source§

fn from(t: T) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(b: bool) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(i: f64) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(i: i64) -> Self

Converts to this type from the input type.
source§

impl TotalDisplay for Value

source§

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

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

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

source§

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> ToSmolStr for T
where T: Display + ?Sized,

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

source§

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

source§

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

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,