pub trait NixValueOps: NixValueRaw {
// Provided methods
fn value_type(&self) -> ValueType { ... }
fn force(&self) -> Result<()> { ... }
fn as_int(&self) -> Result<i64> { ... }
fn as_float(&self) -> Result<f64> { ... }
fn as_bool(&self) -> Result<bool> { ... }
fn as_string(&self) -> Result<String> { ... }
fn as_path(&self) -> Result<String> { ... }
}Expand description
Read access to a Nix value.
Implemented by Value,
primop::PrimOpArg, and
primop::PrimOpValue. All accessors force
the value first, mirroring nix-instantiate-style semantics: a lazy
attribute that resolves to an int is reported as an int, not a thunk.
Provided Methods§
Sourcefn value_type(&self) -> ValueType
fn value_type(&self) -> ValueType
Return the ValueType of this value.
Does not force; an unforced thunk reports as ValueType::Thunk.
Use force (or any as_* accessor) to resolve first.
Sourcefn as_int(&self) -> Result<i64>
fn as_int(&self) -> Result<i64>
Extract as an integer. Forces the value first.
§Errors
Returns an error if forcing fails or the resolved value is not an integer.
Sourcefn as_float(&self) -> Result<f64>
fn as_float(&self) -> Result<f64>
Extract as a float. Forces the value first.
§Errors
Returns an error if forcing fails or the resolved value is not a float.
Sourcefn as_bool(&self) -> Result<bool>
fn as_bool(&self) -> Result<bool>
Extract as a boolean. Forces the value first.
§Errors
Returns an error if forcing fails or the resolved value is not a boolean.