Struct Constant
pub struct Constant<T, M> { /* private fields */ }
Wraps a type so that it implements Load and returns a constant load metric.
This load estimator is primarily useful for testing.
Implementations
impl<T, M: Copy> Constant<T, M>
const fn new(inner: T, load: M) -> SelfWraps a
T-typed service with a constantM-typed load metric.
Trait Implementations
impl<'__pin, T, M> Unpin for Constant<T, M>
where
PinnedFieldsOf<__Origin<'__pin, T, M>>: Unpin,
impl<D: Discover + Unpin, M: Copy> Stream for Constant<D, M>
type Item = Result<Change<<D as Discover>::Key, Constant<<D as Discover>::Service, M>>, <D as Discover>::Error>;fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>Yields the next discovery change set.
impl<S, M, Request> Service<Request> for Constant<S, M>
where
S: Service<Request>,
M: Copy,
type Response = <S as Service<Request>>::Response;type Error = <S as Service<Request>>::Error;type Future = <S as Service<Request>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>fn call(&mut self, req: Request) -> Self::Future
impl<T, M: Copy + PartialOrd> Load for Constant<T, M>
type Metric = M;fn load(&self) -> M
impl<T: Debug, M: Debug> Debug for Constant<T, M>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T, M> Freeze for Constant<T, M>
where
T: Freeze,
M: Freeze,
impl<T, M> RefUnwindSafe for Constant<T, M>
where
T: RefUnwindSafe,
M: RefUnwindSafe,
impl<T, M> Send for Constant<T, M>
where
T: Send,
M: Send,
impl<T, M> Sync for Constant<T, M>
where
T: Sync,
M: Sync,
impl<T, M> UnsafeUnpin for Constant<T, M>
where
T: UnsafeUnpin,
M: UnsafeUnpin,
impl<T, M> UnwindSafe for Constant<T, M>
where
T: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<C, Target> MakeConnection<Target> for Constant<T, M>
where
C: Service<Target>,
<C as Service<Target>>::Response: AsyncRead + AsyncWrite,
type Connection = <C as Service<Target>>::Response;type Error = <C as Service<Target>>::Error;type Future = <C as Service<Target>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future
impl<K, S, E, D> Discover for Constant<T, M>
where
D: TryStream<Ok = Change<K, S>, Error = E> + ?Sized,
K: Eq,
type Key = K;type Service = S;type Error = E;fn poll_discover(self: Pin<&mut D>, cx: &mut Context<'_>) -> Poll<Option<Result<<D as TryStream>::Ok, <D as TryStream>::Error>>>
impl<M, S, Target, Request> MakeService<Target, Request> for Constant<T, M>
where
M: Service<Target, Response = S>,
S: Service<Request>,
type Response = <S as Service<Request>>::Response;type Error = <S as Service<Request>>::Error;type Service = S;type MakeError = <M as Service<Target>>::Error;type Future = <M as Service<Target>>::Future;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future
impl<S> TryStreamExt for Constant<T, M>
where
S: TryStream + ?Sized,
impl<S, T, E> TryStream for Constant<T, M>
where
S: Stream<Item = Result<T, E>> + ?Sized,
type Ok = T;type Error = E;fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>
impl<T> Any for Constant<T, M>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Constant<T, M>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Constant<T, M>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Constant<T, M>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Constant<T, M>
impl<T> StreamExt for Constant<T, M>
where
T: Stream + ?Sized,
impl<T> WithSubscriber for Constant<T, M>
impl<T, Request> ServiceExt<Request> for Constant<T, M>
where
T: Service<Request> + ?Sized,
impl<T, U> Into<U> for Constant<T, M>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Constant<T, M>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Constant<T, M>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>