Struct Optional

pub struct Optional<T> { /* private fields */ }

Optionally forwards requests to an inner service.

If the inner service is None, optional::None is returned as the response.

Implementations

impl<T> Optional<T>

const fn new<Request>(inner: Option<T>) -> Optional<T>
where
    T: Service<Request>,
    T::Error: Into<BoxError>,

Create a new Optional.

Trait Implementations

impl<T, Request> Service<Request> for Optional<T> where T: Service<Request>, T::Error: Into<BoxError>,

type Response = <T as Service<Request>>::Response;
type Error = Box<dyn Error + Sync + Send>;
type Future = ResponseFuture<<T as Service<Request>>::Future>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, request: Request) -> Self::Future

impl<T: Debug> Debug for Optional<T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<T> Freeze for Optional<T> where Option<T>: Freeze,

impl<T> RefUnwindSafe for Optional<T> where Option<T>: RefUnwindSafe,

impl<T> Send for Optional<T> where Option<T>: Send,

impl<T> Sync for Optional<T> where Option<T>: Sync,

impl<T> Unpin for Optional<T> where Option<T>: Unpin,

impl<T> UnsafeUnpin for Optional<T> where Option<T>: UnsafeUnpin,

impl<T> UnwindSafe for Optional<T> where Option<T>: UnwindSafe,

Blanket Implementations

impl<C, Target> MakeConnection<Target> for Optional<T> where C: Service<Target>, <C as Service<Target>>::Response: AsyncRead + AsyncWrite,

impl<M, S, Target, Request> MakeService<Target, Request> for Optional<T> where M: Service<Target, Response = S>, S: Service<Request>,

impl<T> Any for Optional<T> where T: 'static + ?Sized,

impl<T> Borrow<T> for Optional<T> where T: ?Sized,

impl<T> BorrowMut<T> for Optional<T> where T: ?Sized,

impl<T> From<T> for Optional<T>

impl<T> Instrument for Optional<T>

impl<T> WithSubscriber for Optional<T>

impl<T, Request> ServiceExt<Request> for Optional<T> where T: Service<Request> + ?Sized,

impl<T, U> Into<U> for Optional<T> where U: From<T>,

impl<T, U> TryFrom<U> for Optional<T> where U: Into<T>,

impl<T, U> TryInto<U> for Optional<T> where U: TryFrom<T>,