Skip to main content

PrimOpValue

Struct PrimOpValue 

Source
pub struct PrimOpValue<'a> { /* private fields */ }
Expand description

An owned Nix value used within a primop callback.

Unlike PrimOpArg, this owns a GC reference to the underlying value and decrements it on drop. It is returned by ArgAttrs::get and ArgList::get when extracting child values from collections.

Methods mirror those of PrimOpArg: value_type, force, as_int, as_float, as_bool, as_string, as_attrs, and as_list are all available.

Implementations§

Source§

impl<'a> PrimOpValue<'a>

Source

pub fn as_attrs(&self) -> Result<ArgAttrs<'_>>

Interpret this value as an attribute set.

Automatically forces the value if it is a thunk.

Returns an ArgAttrs wrapper that borrows from this value.

§Errors

Returns an error if forcing fails or the resolved value is not an attribute set.

Source

pub fn as_list(&self) -> Result<ArgList<'_>>

Interpret this value as a list.

Automatically forces the value if it is a thunk.

Returns an ArgList wrapper that borrows from this value.

§Errors

Returns an error if forcing fails or the resolved value is not a list.

Trait Implementations§

Source§

impl Drop for PrimOpValue<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PrimOpValue<'a>

§

impl<'a> RefUnwindSafe for PrimOpValue<'a>

§

impl<'a> !Send for PrimOpValue<'a>

§

impl<'a> !Sync for PrimOpValue<'a>

§

impl<'a> Unpin for PrimOpValue<'a>

§

impl<'a> UnsafeUnpin for PrimOpValue<'a>

§

impl<'a> UnwindSafe for PrimOpValue<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> NixValueOps for T
where T: NixValueRaw,

Source§

fn value_type(&self) -> ValueType

Return the ValueType of this value. Read more
Source§

fn force(&self) -> Result<()>

Force evaluation (resolves thunks). Read more
Source§

fn as_int(&self) -> Result<i64>

Extract as an integer. Forces the value first. Read more
Source§

fn as_float(&self) -> Result<f64>

Extract as a float. Forces the value first. Read more
Source§

fn as_bool(&self) -> Result<bool>

Extract as a boolean. Forces the value first. Read more
Source§

fn as_string(&self) -> Result<String>

Extract as a UTF-8 string, realising any string context. Forces the value first. Read more
Source§

fn as_path(&self) -> Result<String>

Extract as a filesystem-path string. Forces the value first. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.