pub trait CookieName {
const NAME: &'static str;
}Expand description
Trait for cookie name markers (similar to HeaderName).
Implement this trait to create a type-safe cookie extractor.
§Example
ⓘ
use fastapi_core::{CookieName, Cookie};
struct SessionId;
impl CookieName for SessionId {
const NAME: &'static str = "session_id";
}
async fn get_session(Cookie(session): Cookie<String, SessionId>) -> impl IntoResponse {
format!("Session: {}", session)
}Required Associated Constants§
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.