Skip to main content

PrimOp

Struct PrimOp 

Source
pub struct PrimOp { /* private fields */ }

Implementations§

Source§

impl PrimOp

Source

pub fn new<const N: usize>( meta: PrimOpMeta<'_, N>, f: Box<dyn Fn(&mut EvalState, &[Value; N]) -> Result<Value>>, ) -> Result<PrimOp>

Create a new primop with the given metadata and implementation.

The primop is not tied to an EvalState; the callback argument comes directly from Nix.

When f returns an Err, the error is propagated to the Nix evaluator. To return a recoverable error, include it in the error chain (e.g. Err(RecoverableError::new("...").into())).

Source

pub fn into_value(self, eval_state: &mut EvalState) -> Result<Value>

Creates a function Value backed by this primop, in the given EvalState.

Consumes the PrimOp as ownership moves to the Nix GC. The returned Value or other references in the Nix heap keep it alive.

This fully consumes the PrimOp because the C API leaves it invalid.

Source

pub fn register_globally(self) -> Result<()>

Registers this primop into future EvalStates.

Per the Nix C API (nix_register_primop), this only affects EvalStates created after the call.

This fully consumes the PrimOp because the C API leaves it invalid.

Trait Implementations§

Source§

impl Drop for PrimOp

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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, 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.