kvarn

Macro extension

source
macro_rules! extension {
    ($trait: ty, $ret: ty, $(($meta:tt) ,)? | $($param:tt: $param_type:ty: $param_type_no_lifetimes:ty :$name:ident ),* |, $(($($(($mut:tt))? $move:ident:$ty:ty),+))?, $code:block) => { ... };
}
Expand description

The ultimate extension-creation macro.

This is used in the various other macros which expand to extensions; use them instead!

§Stability

This macro isn’t considered stable and may change at any time.

§Examples

This is similar to the prepare! macro.

extension!(
    kvarn::extensions::PrepareCall,
    FatResponse,
    | request: &'a mut FatRequest: &mut FatRequest: arg1,
    host: &'a Host: &Host: arg2,
    path: Option<&'a Path>: Option<&Path>: arg3,
    addr: SocketAddr: SocketAddr: arg4 |, , {
        println!("Hello world, from extension macro!");
        FatResponse::no_cache(Response::new(Bytes::from_static(b"Hi!")))
    }
);