#[repr(C)]pub struct vmod_priv {
pub priv_: *mut c_void,
pub len: c_long,
pub methods: *const vmod_priv_methods,
}Fields§
§priv_: *mut c_void§len: c_long§methods: *const vmod_priv_methodsImplementations§
Source§impl vmod_priv
impl vmod_priv
Sourcepub unsafe fn put<T>(
&mut self,
obj: Box<T>,
methods: &'static vmod_priv_methods,
)
pub unsafe fn put<T>( &mut self, obj: Box<T>, methods: &'static vmod_priv_methods, )
Set the object and methods for the vmod_priv, and the corresponding static methods.
SAFETY: The type of obj must match the type of the function pointers in methods.
Sourcepub unsafe extern "C" fn on_fini<T>(
_ctx: *const vrt_ctx,
priv_: *mut c_void,
)
pub unsafe extern "C" fn on_fini<T>( _ctx: *const vrt_ctx, priv_: *mut c_void, )
A Varnish callback function to free a vmod_priv object.
Here we take the ownership and immediately drop the object of type T.
Note that here we get *priv_ directly, not the *vmod_priv
SAFETY: priv_ must be a valid pointer to a T object or NULL.
Source§impl vmod_priv
impl vmod_priv
Sourcepub unsafe fn take<T>(&mut self) -> Option<Box<T>>
pub unsafe fn take<T>(&mut self) -> Option<Box<T>>
Transfer ownership of the object to the caller, cleaning up the internal state.
SAFETY: priv_ must reference a valid T object pointer or NULL
pub unsafe fn take_per_vcl<T>(&mut self) -> Box<PerVclState<T>>
Sourcepub unsafe fn get_ref<T>(&self) -> Option<&T>
pub unsafe fn get_ref<T>(&self) -> Option<&T>
Use the object as a reference, without taking ownership.
SAFETY:
priv_must reference a validTobject pointer orNULLtake()must not be called on the samevmod_privobject until the returned reference is dropped- cleanup must not be done on the object until the returned reference is dropped
- assumes
Box<T>is equivalent to&Twhen used as a readonly reference, i.e. a box is just a pointer
Trait Implementations§
impl Copy for vmod_priv
Auto Trait Implementations§
impl Freeze for vmod_priv
impl RefUnwindSafe for vmod_priv
impl !Send for vmod_priv
impl !Sync for vmod_priv
impl Unpin for vmod_priv
impl UnwindSafe for vmod_priv
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