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
impl Value
sourcepub async fn into_contextful_json(
self,
co: &GenCo,
) -> Result<(Json, NixContext), ErrorKind>
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
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
source§type Parameters = Parameters
type Parameters = Parameters
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.source§type Strategy = BoxedStrategy<Value>
type Strategy = BoxedStrategy<Value>
Strategy
used to generate values of type Self
.source§fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy
source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<CatchableErrorKind> for Value
impl From<CatchableErrorKind> for Value
source§fn from(c: CatchableErrorKind) -> Value
fn from(c: CatchableErrorKind) -> Value
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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