Skip to main content

varnish_sys/
utils.rs

1use crate::ffi::director;
2use crate::vcl::{VclBackend, VclResponse};
3
4/// Return the private pointer as a reference to the [`VclBackend`] object
5/// FIXME: should it return a `&mut` instead?
6pub fn get_backend<S: VclBackend<T>, T: VclResponse>(v: &director) -> &S {
7    unsafe {
8        v.priv_
9            .cast::<S>()
10            .as_ref()
11            .expect("backend priv_ pointer is null")
12    }
13}