Struct vmod_priv

Source
#[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_methods

Implementations§

Source§

impl vmod_priv

Source

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.

Source

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

pub unsafe extern "C" fn on_fini_per_vcl<T>( ctx: *const vrt_ctx, priv_: *mut c_void, )

A Varnish callback function to clean up the PerVclState object. Similar to on_fini, but also unregisters filters.

SAFETY: priv_ must be a valid pointer to a T object or NULL.

Source§

impl vmod_priv

Source

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

Source

pub unsafe fn take_per_vcl<T>(&mut self) -> Box<PerVclState<T>>

Source

pub unsafe fn get_ref<T>(&self) -> Option<&T>

Use the object as a reference, without taking ownership.

SAFETY:

  • priv_ must reference a valid T object pointer or NULL
  • take() must not be called on the same vmod_priv object 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 &T when used as a readonly reference, i.e. a box is just a pointer

Trait Implementations§

Source§

impl Clone for vmod_priv

Source§

fn clone(&self) -> vmod_priv

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for vmod_priv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for vmod_priv

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for vmod_priv

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.