pub trait Service<Request> {
type Response;
type Permit<'a>
where Self: 'a;
// Required methods
async fn acquire(&self) -> Self::Permit<'_>;
async fn call<'a>(
permit: Self::Permit<'a>,
request: Request,
) -> Self::Response
where Self: 'a;
}
Expand description
An asynchronous function call, which can only be executed after obtaining a permit.
§Example
use burger::{service_fn::ServiceFn, *};
let svc = service_fn(|x: usize| async move { x.to_string() });
let permit = svc.acquire().await;
let response = ServiceFn::call(permit, 32).await;
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.