Struct runtime_injector_actix::Injected [−][src]
pub struct Injected<R: Request>(_);
Expand description
An injected request. Any request to the Injector
can be injected by
wrapping it in this type and providing it as a parameter to your request
handler.
Example
use actix_web::{get, App, HttpResponse, HttpServer, Responder}; use runtime_injector_actix::{ constant, define_module, Injected, Injector, Svc, }; #[actix_web::main] async fn main() -> std::io::Result<()> { let mut builder = Injector::builder(); builder.add_module(define_module! { services = [constant(4i32)], }); let injector = builder.build(); HttpServer::new(move || { App::new().app_data(injector.clone()).service(index) }) .bind(("127.0.0.1", 8080))? .run() .await } #[get("/")] async fn index(my_service: Injected<Svc<i32>>) -> impl Responder { HttpResponse::Ok().body(format!("injected value is {}", *my_service)) }
Implementations
impl<R: Request> Injected<R>
[src]
impl<R: Request> Injected<R>
[src]pub fn into_inner(value: Injected<R>) -> R
[src]
pub fn into_inner(value: Injected<R>) -> R
[src]Converts an Injected<R>
to its inner value.
Trait Implementations
impl<R: Request> FromRequest for Injected<R>
[src]
impl<R: Request> FromRequest for Injected<R>
[src]type Error = Error
type Error = Error
The associated error which can be returned.
fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future
[src]
fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future
[src]Convert request to a Self
fn extract(req: &HttpRequest) -> Self::Future
[src]
fn extract(req: &HttpRequest) -> Self::Future
[src]Convert request to a Self Read more
impl<R: Ord + Request> Ord for Injected<R>
[src]
impl<R: Ord + Request> Ord for Injected<R>
[src]impl<R: PartialOrd + Request> PartialOrd<Injected<R>> for Injected<R>
[src]
impl<R: PartialOrd + Request> PartialOrd<Injected<R>> for Injected<R>
[src]fn partial_cmp(&self, other: &Injected<R>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Injected<R>) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<R: Eq + Request> Eq for Injected<R>
[src]
impl<R: Request> StructuralEq for Injected<R>
[src]
impl<R: Request> StructuralPartialEq for Injected<R>
[src]
Auto Trait Implementations
impl<R> RefUnwindSafe for Injected<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for Injected<R> where
R: Send,
R: Send,
impl<R> Sync for Injected<R> where
R: Sync,
R: Sync,
impl<R> Unpin for Injected<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for Injected<R> where
R: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Interface for T where
T: Service,
[src]
impl<T> Interface for T where
T: Service,
[src]impl<T> RequestParameter for T where
T: Service + Clone + AsAny,
[src]
impl<T> RequestParameter for T where
T: Service + Clone + AsAny,
[src]pub fn clone_dyn(&self) -> Box<dyn RequestParameter + 'static, Global>
[src]
pub fn clone_dyn(&self) -> Box<dyn RequestParameter + 'static, Global>
[src]Clones this parameter into a boxed trait object.
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> InterfaceFor<T> for T where
T: Service,
[src]
T: Service,
impl<T> Service for T where
T: Any + Send + Sync + ?Sized,
[src]
T: Any + Send + Sync + ?Sized,