Struct Extensions
pub struct Extensions { /* private fields */ }Expand description
Implementations§
§impl Extensions
impl Extensions
pub fn new() -> Extensions
pub fn new() -> Extensions
Create an empty Extensions store.
pub fn insert<T>(&self, val: T) -> &Twhere
T: Extension,
pub fn insert<T>(&self, val: T) -> &Twhere
T: Extension,
Insert a type T into this Extensions store.
This method returns a refence to the just insert value
If the value you are inserting is an Arc<T>, prefer using
Self::insert_arc() to prevent the double indirection of storing
an Arc<Arc<T>>. This happens because internally we use a type erased
Arc to store the actual value.
pub fn insert_arc<T>(&self, val: Arc<T>) -> Arc<T>where
T: Extension,
pub fn insert_arc<T>(&self, val: Arc<T>) -> Arc<T>where
T: Extension,
Insert a type Arc<T> into this [Extensions] store.
This method returns a a cloned Arc of the value just inserted
If the value you are inserting is not an Arc<T> or you don’t
need a cloned Arc<T> prefer using Self::insert()
pub fn extend(&self, other: &Extensions)
pub fn extend(&self, other: &Extensions)
Extend this Extensions store with the other Extensions.
The other Extensionss will be appended behind the current ones
pub fn contains<T>(&self) -> boolwhere
T: Extension,
pub fn contains<T>(&self) -> boolwhere
T: Extension,
Returns true if the Extensions store contains the given type.
pub fn get_ref<T>(&self) -> Option<&T>where
T: Extension,
pub fn get_ref<T>(&self) -> Option<&T>where
T: Extension,
Get a reference to the most recently insert item of type T, or insert in case no item was found
If an owned Arc<T> is needed prefer using Self::get_arc()
Self::get_ref will return the last added item T, in most cases this is exactly what you want, but
if you need the oldest item T use Self::first_ref
pub fn get_arc<T>(&self) -> Option<Arc<T>>where
T: Extension,
pub fn get_arc<T>(&self) -> Option<Arc<T>>where
T: Extension,
Get an owned Arc<T> of the most recently insert item of type T, or insert in case no item was found
If a reference is needed prefer using Self::get_ref()
Self::get_arc will return the last added item T, in most cases this is exactly what you want, but
if you need the oldest item T use Self::first_arc
pub fn get_ref_or_insert<T, F>(&self, create_fn: F) -> &T
pub fn get_ref_or_insert<T, F>(&self, create_fn: F) -> &T
Get a reference to the most recently insert item of type T, or insert in case no item was found
If an owned Arc<T> is needed or inserting prefer using Self::get_arc_or_insert()
pub fn get_arc_or_insert<T, F>(&self, create_fn: F) -> Arc<T>
pub fn get_arc_or_insert<T, F>(&self, create_fn: F) -> Arc<T>
Get an owned Arc<T> of the most recently insert item of type T, or insert in case no item was found
If a reference is needed or the type being inserted in not an Arc<T> prefer using Self::get_ref_or_insert()
pub fn first_ref<T>(&self) -> Option<&T>where
T: Extension,
pub fn first_ref<T>(&self) -> Option<&T>where
T: Extension,
Get a shared reference to the oldest inserted item of type T
If an owned Arc<T> is needed prefer using Self::get_arc()
Self::first_ref will return the first added item T, in most cases this is not what you want,
instead use Self::get_ref to get the most recently inserted item T
pub fn first_arc<T>(&self) -> Option<Arc<T>>where
T: Extension,
pub fn first_arc<T>(&self) -> Option<Arc<T>>where
T: Extension,
Get an owned Arc<T> of the oldest inserted item of type T
If a reference is needed prefer using Self::first_ref()
Self::first_arc will return the first added item T, in most cases this is not what you want,
instead use Self::get_arc to get the most recently inserted item T
pub fn iter_ref<T>(&self) -> impl Iterator<Item = &T>where
T: Extension,
pub fn iter_ref<T>(&self) -> impl Iterator<Item = &T>where
T: Extension,
Iterate over all the inserted items of type T as shared references.
Items are ordered from oldest to newest.
pub fn iter_arc<T>(&self) -> impl Iterator<Item = Arc<T>>where
T: Extension,
pub fn iter_arc<T>(&self) -> impl Iterator<Item = Arc<T>>where
T: Extension,
Iterate over all the inserted items of type T as cloned Arc values.
Items are ordered from oldest to newest.
pub fn iter_all(&self) -> impl Iterator<Item = &TypeErasedExtension>
pub fn iter_all(&self) -> impl Iterator<Item = &TypeErasedExtension>
Iter over all the TypeErasedExtension
This can be used to efficiently combine different types of Extensions in
only a single iteration. TypeErasedExtension exposes methods to easily
convert it back to type T if it matches the erasaed type stored internally.
Trait Implementations§
§impl Clone for Extensions
impl Clone for Extensions
§fn clone(&self) -> Extensions
fn clone(&self) -> Extensions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Extensions
impl Debug for Extensions
§impl Default for Extensions
impl Default for Extensions
§fn default() -> Extensions
fn default() -> Extensions
§impl ExtensionsRef for Extensions
impl ExtensionsRef for Extensions
§fn extensions(&self) -> &Extensions
fn extensions(&self) -> &Extensions
Extensions store§impl From<Extensions> for RequestExtensions
impl From<Extensions> for RequestExtensions
§fn from(value: Extensions) -> RequestExtensions
fn from(value: Extensions) -> RequestExtensions
§impl FromRequest for Extensions
impl FromRequest for Extensions
§type Rejection = Infallible
type Rejection = Infallible
§async fn from_request(
req: Request,
) -> Result<Extensions, <Extensions as FromRequest>::Rejection>
async fn from_request( req: Request, ) -> Result<Extensions, <Extensions as FromRequest>::Rejection>
§impl IntoResponse for Extensions
impl IntoResponse for Extensions
§fn into_response(self) -> Response
fn into_response(self) -> Response
§impl IntoResponseParts for Extensions
impl IntoResponseParts for Extensions
§type Error = Infallible
type Error = Infallible
§fn into_response_parts(
self,
res: ResponseParts,
) -> Result<ResponseParts, <Extensions as IntoResponseParts>::Error>
fn into_response_parts( self, res: ResponseParts, ) -> Result<ResponseParts, <Extensions as IntoResponseParts>::Error>
Auto Trait Implementations§
impl Freeze for Extensions
impl RefUnwindSafe for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl UnsafeUnpin for Extensions
impl UnwindSafe for Extensions
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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§impl<R> IntoEndpointService<()> for R
impl<R> IntoEndpointService<()> for R
type Service = StaticService<R>
§fn into_endpoint_service(self) -> <R as IntoEndpointService<()>>::Service
fn into_endpoint_service(self) -> <R as IntoEndpointService<()>>::Service
rama_core::Service.§impl<R, State> IntoEndpointServiceWithState<(), State> for R
impl<R, State> IntoEndpointServiceWithState<(), State> for R
type Service = StaticService<R>
§fn into_endpoint_service_with_state(
self,
_state: State,
) -> <R as IntoEndpointServiceWithState<(), State>>::Service
fn into_endpoint_service_with_state( self, _state: State, ) -> <R as IntoEndpointServiceWithState<(), State>>::Service
rama_core::Service with state.§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more