Struct RequestExtensions
pub struct RequestExtensions(/* private fields */);Expand description
Read-only copy of the parent request extensions.
This extension can be made available as part of a response.
Methods from Deref<Target = Extensions>§
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 RequestExtensions
impl Clone for RequestExtensions
§fn clone(&self) -> RequestExtensions
fn clone(&self) -> RequestExtensions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for RequestExtensions
impl Debug for RequestExtensions
§impl Deref for RequestExtensions
impl Deref for RequestExtensions
§type Target = Extensions
type Target = Extensions
§fn deref(&self) -> &<RequestExtensions as Deref>::Target
fn deref(&self) -> &<RequestExtensions as Deref>::Target
§impl From<Extensions> for RequestExtensions
impl From<Extensions> for RequestExtensions
§fn from(value: Extensions) -> RequestExtensions
fn from(value: Extensions) -> RequestExtensions
impl Extension for RequestExtensions
impl HttpExtension for RequestExtensions
Auto Trait Implementations§
impl Freeze for RequestExtensions
impl RefUnwindSafe for RequestExtensions
impl Send for RequestExtensions
impl Sync for RequestExtensions
impl Unpin for RequestExtensions
impl UnsafeUnpin for RequestExtensions
impl UnwindSafe for RequestExtensions
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<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