pub struct PrimOp { /* private fields */ }Expand description
A Nix primitive operation (primop) wrapping a Rust closure.
After construction with PrimOp::new, the primop can be:
- Registered as a global builtin via
PrimOp::register(must happen before creating anyEvalState). - Embedded in a value via
PrimOp::into_valuefor use as a first-class function inside anEvalState.
Implementations§
Source§impl PrimOp
impl PrimOp
Sourcepub fn new<F>(
context: &Arc<Context>,
name: &str,
arity: u32,
doc: Option<&str>,
f: F,
) -> Result<Self>
pub fn new<F>( context: &Arc<Context>, name: &str, arity: u32, doc: Option<&str>, f: F, ) -> Result<Self>
Create a new primop backed by the given Rust closure.
§Arguments
context: the Nix context.name: the name of the primop as it will appear in Nix.arity: number of arguments the primop accepts.doc: optional documentation string.f: the Rust closure to invoke.
§Errors
Returns an error if the name or doc string contains an interior NUL byte, or if the underlying allocation fails.
Sourcepub fn register(self, context: &Context) -> Result<()>
pub fn register(self, context: &Context) -> Result<()>
Register this primop as a global Nix builtin.
After this call the primop will appear in builtins.* for all
EvalState instances created after this call.
This consumes self; the underlying pointer is transferred to the
global registry and is no longer accessible.
§Errors
Returns an error if the registration fails.
Sourcepub fn into_value(self, state: &EvalState) -> Result<Value<'_>>
pub fn into_value(self, state: &EvalState) -> Result<Value<'_>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PrimOp
impl RefUnwindSafe for PrimOp
impl !Sync for PrimOp
impl Unpin for PrimOp
impl UnsafeUnpin for PrimOp
impl UnwindSafe for PrimOp
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
Mutably borrows from an owned value. Read more