HandlerMetadata

Trait HandlerMetadata 

pub trait HandlerMetadata {
    const PATH: &'static str;
    const METHOD: Method;
}
Expand description

A trait that represents a handler metadata.

They are used to store the metadata of a handler, and are automatically implemented by the #[get], #[post], etc. macros.

This trait is used internally by Catalyzer, and should not be implemented manually.

With #[get]:

#[get("/")]
fn index() {
    "Hello, world!"
}

Manual implementation:

async fn index() -> impl ::catalyzer::res::IntoRawResponse {
    "Hello, world!"
}
#[doc(hidden)]
#[repr(transparent)]
#[allow(non_camel_case_types)]
struct index_metadata;
impl ::catalyzer::internals::HandlerMetadata for index_metadata {
    const PATH: &'static str = "/";
    const METHOD: ::catalyzer::internals::Method = ::catalyzer::internals::Method::GET;
}

Required Associated Constants§

Source

const PATH: &'static str

Path to mount the handler on.

Source

const METHOD: Method

Method to handle.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§