pub struct SelectedOperation { /* private fields */ }Expand description
A read-only view of the protocol and operation selected by routing, with the operation’s request-body limits.
The protocol is erased: everything after routing works through dyn ServerProtocol.
The operation schema is stored for consumers that are not generic over the operation:
middleware and FromParts extractors use
get_from_request or get_from_extensions to
learn which operation was selected — for logging, auth, or metrics — without naming an Op
type. See the middleware example on ServerProtocol.
Routing stores this view in a private extension carrier. Inserting or removing
SelectedOperation directly in request extensions does not change the routed selection.
Middleware must preserve request extensions: clearing or replacing all extensions removes
the carrier, causing the upgrade or missing-handler fallback to return an empty 500
without polling the body or invoking the handler. Routing may already have collected the body
before middleware runs.
Implementations§
Source§impl SelectedOperation
impl SelectedOperation
Sourcepub fn get_from_request<B>(request: &Request<B>) -> Option<&Self>
pub fn get_from_request<B>(request: &Request<B>) -> Option<&Self>
Borrows the protocol and operation selected for this request from its extensions.
Returns None if no selection is stored, including before schema routing runs.
Sourcepub fn get_from_extensions(extensions: &Extensions) -> Option<&Self>
pub fn get_from_extensions(extensions: &Extensions) -> Option<&Self>
Borrows the routed selection from request extensions, including in a
FromParts extractor.
Returns None before routing or if middleware discarded the request extensions.
Sourcepub fn protocol(&self) -> &SharedServerProtocol
pub fn protocol(&self) -> &SharedServerProtocol
The selected protocol.
Sourcepub fn operation(&self) -> &'static OperationSchema<'static>
pub fn operation(&self) -> &'static OperationSchema<'static>
The routed operation’s schema, for code that cannot name the operation type.
Sourcepub fn request_body_config(&self) -> RequestBodyCollectionConfig
pub fn request_body_config(&self) -> RequestBodyCollectionConfig
The routed operation’s request-body collection limits, resolved when the router was built.
Carrying them here keeps the per-operation upgrade services free of per-operation state.
Trait Implementations§
Source§impl Clone for SelectedOperation
impl Clone for SelectedOperation
Source§fn clone(&self) -> SelectedOperation
fn clone(&self) -> SelectedOperation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SelectedOperation
impl !RefUnwindSafe for SelectedOperation
impl Send for SelectedOperation
impl Sync for SelectedOperation
impl Unpin for SelectedOperation
impl UnsafeUnpin for SelectedOperation
impl !UnwindSafe for SelectedOperation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more