varnish_sys::vcl

Struct Backend

Source
pub struct Backend<S: Serve<T>, T: Transfer> { /* private fields */ }
Expand description

Fat wrapper around VCL_BACKEND.

It will handle almost all the necessary boilerplate needed to create a vmod. Most importantly, it destroys/unregisters the backend as part of it’s Drop implementation, and will convert the C methods to something more idiomatic.

Once created, a Backend’s sole purpose is to exist as a C reference for the VCL. As a result, you don’t want to drop it until after all the transfers are done. The most common way is just to have the backend be part of a vmod object because the object won’t be dropped until the VCL is discarded and that can only happen once all the backend fetches are done.

Implementations§

Source§

impl<S: Serve<T>, T: Transfer> Backend<S, T>

Source

pub fn get_inner(&self) -> &S

Access the inner type wrapped by Backend. Note that it isn’t mut as other threads are likely to have access to it too.

Source

pub fn vcl_ptr(&self) -> VCL_BACKEND

Return the C pointer wrapped by the Backend. Conventionally used by the .backend() methods of VCL objects.

Source

pub fn new( ctx: &mut Ctx<'_>, name: &str, be: S, has_probe: bool, ) -> VclResult<Self>

Create a new builder, wrapping the inner structure (that implements Serve), calling the backend name. If the backend has a probe attached to it, set has_probe to true.

Trait Implementations§

Source§

impl<S: Debug + Serve<T>, T: Debug + Transfer> Debug for Backend<S, T>

Source§

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

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

impl<S: Serve<T>, T: Transfer> Drop for Backend<S, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<S, T> Freeze for Backend<S, T>

§

impl<S, T> RefUnwindSafe for Backend<S, T>

§

impl<S, T> !Send for Backend<S, T>

§

impl<S, T> !Sync for Backend<S, T>

§

impl<S, T> Unpin for Backend<S, T>
where T: Unpin,

§

impl<S, T> UnwindSafe for Backend<S, T>
where T: UnwindSafe, S: UnwindSafe,

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.