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, NixContext)>),
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, NixContext)>)
FinaliseRequest(bool)
Catchable(Box<CatchableErrorKind>)
Implementations§
source§impl Value
impl Value
sourcepub async fn into_contextful_json(
self,
co: &GenCo
) -> Result<Result<(Json, NixContext), CatchableErrorKind>, ErrorKind>
pub async fn into_contextful_json( self, co: &GenCo ) -> Result<Result<(Json, NixContext), CatchableErrorKind>, ErrorKind>
Transforms the structure into a JSON and accumulate all encountered context in the second’s element of the return type.
sourcepub(crate) async fn into_contextful_json_generator(
self,
co: GenCo
) -> Result<Value, ErrorKind>
pub(crate) async fn into_contextful_json_generator( self, co: GenCo ) -> Result<Value, ErrorKind>
Generator version of the above, which wraps responses in
Value::Json
.
source§impl Value
impl Value
sourcepub fn attrs(attrs: NixAttrs) -> Self
pub fn attrs(attrs: NixAttrs) -> Self
Construct a Value::Attrs
from a NixAttrs
.
sourcepub(crate) async fn deep_force(
self,
co: GenCo,
span: Span
) -> Result<Value, ErrorKind>
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.
sourceasync fn deep_force_(
myself: Value,
co: GenCo,
span: Span
) -> Result<Option<Value>, ErrorKind>
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
pub async fn coerce_to_string( self, co: GenCo, kind: CoercionKind, span: Span ) -> Result<Value, ErrorKind>
sourcepub async fn coerce_to_string_(
self,
co: &GenCo,
kind: CoercionKind,
span: Span
) -> Result<Value, ErrorKind>
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.
pub(crate) async fn nix_eq_owned_genco( self, other: Value, co: GenCo, ptr_eq: PointerEquality, span: Span ) -> Result<Value, ErrorKind>
sourcepub(crate) async fn nix_eq(
self,
other: Value,
co: &GenCo,
ptr_eq: PointerEquality,
span: Span
) -> Result<Value, ErrorKind>
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
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>
sourcepub fn to_str(&self) -> Result<NixString, ErrorKind>
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.
pub fn to_contextful_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
pub fn is_catchable(&self) -> bool
sourcepub async fn nix_cmp_ordering(
self,
other: Self,
co: GenCo,
span: Span
) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind>
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.
async fn nix_cmp_ordering_( myself: Self, other: Self, co: GenCo, span: Span ) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind>
pub async fn force(self, co: &GenCo, span: Span) -> Result<Value, ErrorKind>
pub async fn force_owned_genco( self, co: GenCo, span: Span ) -> 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
.