Enum tvix_eval::value::Value

source ·
pub enum Value {
Show 18 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>), Json(Box<Value>), 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>)

§

Json(Box<Value>)

§

FinaliseRequest(bool)

§

Catchable(Box<CatchableErrorKind>)

Implementations§

source§

impl Value

source

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

source

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

Generator version of the above, which wraps responses in Value::Json.

source§

impl Value

Constructors

source

pub fn attrs(attrs: NixAttrs) -> Self

Construct a Value::Attrs from a NixAttrs.

source§

impl Value

source

pub(crate) async fn deep_force( self, co: GenCo, span: LightSpan ) -> 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: LightSpan ) -> 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: LightSpan ) -> Result<Value, ErrorKind>

source

pub async fn coerce_to_string_( self, co: &GenCo, kind: CoercionKind, span: LightSpan ) -> 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: LightSpan ) -> Result<Value, ErrorKind>

source

pub(crate) async fn nix_eq( self, other: Value, co: &GenCo, ptr_eq: PointerEquality, span: LightSpan ) -> 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: LightSpan ) -> 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: LightSpan ) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind>

source

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

source

pub async fn force_owned_genco( self, co: GenCo, span: LightSpan ) -> 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.

Trait Implementations§

source§

impl Arbitrary for Value

§

type Parameters = Parameters

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

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 Valuewhere 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 Valuewhere 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 !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

impl<T> ToString for Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

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