Skip to main content

Director

Struct Director 

Source
pub struct Director<D: VclDirector> { /* private fields */ }
Expand description

Safe wrapper around a struct director pointer with a trait implementation

This struct wraps a C director along with a Rust implementation that provides the director’s behavior through the VclDirector trait. The wrapper handles the FFI boundary and ensures proper lifetime management.

Directors are typically used to implement load balancing strategies (round-robin, random, hash-based, etc.) by selecting from multiple backends.

Implementations§

Source§

impl<D: VclDirector> Director<D>

Source

pub fn new( ctx: &mut Ctx<'_>, director_type: &str, vcl_name: &str, inner: D, ) -> VclResult<Self>

Create a new director by calling VRT_AddDirector

This registers the director with Varnish and sets up the appropriate callbacks. The director will be automatically unregistered when dropped.

Source

pub fn get_inner(&self) -> &D

Access the bep director implementation

Source

pub fn get_inner_mut(&mut self) -> &mut D

Access the bep director implementation mutably

Source

pub fn resolve(&self, ctx: &Ctx<'_>) -> VCL_BACKEND

Resolve this director to a backend using VRT_DirectorResolve

This calls into Varnish’s resolution mechanism, which will invoke the director’s resolve method if needed.

Source

pub fn probe(&self, ctx: &Ctx<'_>) -> ProbeResult

Check if this director is healthy using VRT_Healthy

Trait Implementations§

Source§

impl<D: VclDirector> AsRef<BackendRef> for Director<D>

Source§

fn as_ref(&self) -> &BackendRef

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<D: Debug + VclDirector> Debug for Director<D>

Source§

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

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

impl<D: VclDirector> Drop for Director<D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<D> !Send for Director<D>

§

impl<D> !Sync for Director<D>

§

impl<D> Freeze for Director<D>

§

impl<D> RefUnwindSafe for Director<D>
where D: RefUnwindSafe,

§

impl<D> Unpin for Director<D>

§

impl<D> UnsafeUnpin for Director<D>

§

impl<D> UnwindSafe for Director<D>
where D: 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.