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(Value),
FinaliseRequest(bool),
Catchable(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(Value)
FinaliseRequest(bool)
Catchable(CatchableErrorKind)
Implementations§
source§impl Value
impl Value
Constructors
sourcepub fn attrs(attrs: NixAttrs) -> Self
pub fn attrs(attrs: NixAttrs) -> Self
Construct a Value::Attrs
from a NixAttrs
.
source§impl Value
impl Value
sourcepub(crate) async fn deep_force(
self,
co: GenCo,
thunk_set: SharedThunkSet
) -> Result<Value, ErrorKind>
pub(crate) async fn deep_force( self, co: GenCo, thunk_set: SharedThunkSet ) -> Result<Value, ErrorKind>
Deeply forces a value, traversing e.g. lists and attribute sets and forcing their contents, too.
This is a generator function.
sourcepub async fn coerce_to_string(
self,
co: GenCo,
kind: CoercionKind
) -> Result<Value, ErrorKind>
pub async fn coerce_to_string( self, co: GenCo, kind: CoercionKind ) -> Result<Value, ErrorKind>
Coerce a Value
to a string. See CoercionKind
for a rundown of what
input types are accepted under what circumstances.
sourcepub(crate) async fn nix_eq(
self,
other: Value,
co: GenCo,
ptr_eq: PointerEquality
) -> Result<Value, ErrorKind>
pub(crate) async fn nix_eq( self, other: Value, co: GenCo, ptr_eq: PointerEquality ) -> 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
pub fn type_of(&self) -> &'static str
pub fn as_bool(&self) -> Result<bool, ErrorKind>
pub fn as_int(&self) -> Result<i64, ErrorKind>
pub fn as_float(&self) -> Result<f64, ErrorKind>
pub fn to_str(&self) -> Result<NixString, ErrorKind>
pub fn to_path(&self) -> Result<Box<PathBuf>, ErrorKind>
pub fn to_attrs(&self) -> Result<Box<NixAttrs>, ErrorKind>
pub fn to_list(&self) -> Result<NixList, ErrorKind>
pub fn as_closure(&self) -> Result<Rc<Closure>, ErrorKind>
pub fn as_list_mut(&mut self) -> Result<&mut NixList, ErrorKind>
pub fn is_path(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_attrs(&self) -> bool
sourcepub async fn nix_cmp_ordering(
self,
other: Self,
co: GenCo
) -> Result<Option<Ordering>, ErrorKind>
pub async fn nix_cmp_ordering( self, other: Self, co: GenCo ) -> Result<Option<Ordering>, ErrorKind>
Compare self
against other using (fallible) Nix ordering semantics.
Note that as this returns an Option<Ordering>
it can not directly be
used as a generator function in the VM. The exact use depends on the
callsite, as the meaning is interpreted in different ways e.g. based on
the comparison operator used.
The function is intended to be used from within other generator
functions or gen!
blocks.
async fn nix_cmp_ordering_( myself: Self, other: Self, co: GenCo ) -> Result<Option<Ordering>, ErrorKind>
pub async fn force(self, co: GenCo, span: LightSpan) -> Result<Value, ErrorKind>
Trait Implementations§
source§impl Arbitrary for Value
impl Arbitrary for Value
§type Parameters = Parameters
type Parameters = Parameters
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = BoxedStrategy<Value>
type Strategy = BoxedStrategy<Value>
Strategy
used to generate values of type Self
.