pub struct Context { /* private fields */ }Expand description
A context for error handling, when interacting directly with the generated bindings for the C API in [nix_bindings_util_sys].
The nix-store and nix-expr libraries that consume this type internally store a private context in their EvalState and Store structs to avoid allocating a new context for each operation. The state of a context is irrelevant when used correctly (e.g. with check_call!), so it’s safe to reuse, and safe to allocate more contexts in methods such as Clone::clone.
Implementations§
Source§impl Context
impl Context
pub fn new() -> Self
Sourcepub fn ptr(&mut self) -> *mut c_context
pub fn ptr(&mut self) -> *mut c_context
Access the C context pointer.
We recommend to use check_call! if possible.
Sourcepub fn check_err(&self) -> Result<()>
pub fn check_err(&self) -> Result<()>
Check the error code and return an error if it’s not NIX_OK.
We recommend to use check_call! if possible.
pub fn clear(&mut self)
pub fn check_err_and_clear(&mut self) -> Result<()>
pub fn check_one_call_or_key_none<T, F: FnOnce(*mut c_context) -> T>( &mut self, f: F, ) -> Result<Option<T>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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