pub struct Extension<T>(pub T);Expand description
Extracts a value from request extensions.
Use this to access arbitrary types injected by middleware or other
infrastructure. Unlike State, extensions are per-request.
§Example
use typeway_server::Extension;
#[derive(Clone)]
struct RequestId(String);
async fn handler(Extension(id): Extension<RequestId>) -> String {
format!("Request: {}", id.0)
}Tuple Fields§
§0: TTrait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Extension<T>where
T: Freeze,
impl<T> RefUnwindSafe for Extension<T>where
T: RefUnwindSafe,
impl<T> Send for Extension<T>where
T: Send,
impl<T> Sync for Extension<T>where
T: Sync,
impl<T> Unpin for Extension<T>where
T: Unpin,
impl<T> UnsafeUnpin for Extension<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Extension<T>where
T: 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