pub struct Cookie<T, N> {
pub value: T,
/* private fields */
}Expand description
Cookie value extractor.
Extracts a single cookie value from the Cookie request header using
a type-safe name marker.
§Example
ⓘ
use fastapi_core::{Cookie, CookieName};
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)
}Fields§
§value: TThe extracted cookie value.
Implementations§
Trait Implementations§
Source§impl<T, N> FromRequest for Cookie<T, N>
impl<T, N> FromRequest for Cookie<T, N>
Source§type Error = CookieExtractError
type Error = CookieExtractError
Error type when extraction fails.
Source§async fn from_request(
_ctx: &RequestContext,
req: &mut Request,
) -> Result<Self, Self::Error>
async fn from_request( _ctx: &RequestContext, req: &mut Request, ) -> Result<Self, Self::Error>
Extract a value from the request. Read more
Auto Trait Implementations§
impl<T, N> Freeze for Cookie<T, N>where
T: Freeze,
impl<T, N> RefUnwindSafe for Cookie<T, N>where
T: RefUnwindSafe,
N: RefUnwindSafe,
impl<T, N> Send for Cookie<T, N>
impl<T, N> Sync for Cookie<T, N>
impl<T, N> Unpin for Cookie<T, N>
impl<T, N> UnwindSafe for Cookie<T, N>where
T: UnwindSafe,
N: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).