pub struct Service<T>(pub Arc<T>);Expand description
Axum extractor that retrieves a service T from the application’s service registry.
The inner value is an Arc<T>, so cloning the extractor is cheap.
Returns a 500 Internal Server Error if T was not registered before the server started.
§Example
use modo::service::Service;
struct MyService;
async fn handler(Service(svc): Service<MyService>) {
// svc is Arc<MyService>
}Tuple Fields§
§0: Arc<T>Trait Implementations§
Source§impl<T: Send + Sync + 'static> FromCronContext for Service<T>
impl<T: Send + Sync + 'static> FromCronContext for Service<T>
Source§fn from_cron_context(ctx: &CronContext) -> Result<Self>
fn from_cron_context(ctx: &CronContext) -> Result<Self>
Attempt to extract
Self from the given context. Read moreSource§impl<T: Send + Sync + 'static> FromJobContext for Service<T>
impl<T: Send + Sync + 'static> FromJobContext for Service<T>
Source§fn from_job_context(ctx: &JobContext) -> Result<Self>
fn from_job_context(ctx: &JobContext) -> Result<Self>
Extract
Self from the job context, returning an error if extraction
fails. Read moreSource§impl<S, T> FromRequestParts<S> for Service<T>
impl<S, T> FromRequestParts<S> for Service<T>
Auto Trait Implementations§
impl<T> Freeze for Service<T>
impl<T> RefUnwindSafe for Service<T>where
T: RefUnwindSafe,
impl<T> Send for Service<T>
impl<T> Sync for Service<T>
impl<T> Unpin for Service<T>
impl<T> UnsafeUnpin for Service<T>
impl<T> UnwindSafe for Service<T>where
T: RefUnwindSafe,
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
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.