Struct PeekRouter
pub struct PeekRouter<P, T, F = RejectService> { /* private fields */ }std only.Expand description
A generic Service router driven by a fail-fast PeekVerdict predicate.
Peeking uses a grow-on-demand heap buffer and replays all read bytes. Any
outcome other than PeekVerdict::Match dispatches to the fallback.
Implementations§
§impl<P, T> PeekRouter<P, T>
impl<P, T> PeekRouter<P, T>
pub fn new(predicate: P, acceptor: T) -> PeekRouter<P, T>
pub fn new(predicate: P, acceptor: T) -> PeekRouter<P, T>
Create a router that rejects non-matching input by default.
pub fn with_fallback<F>(self, fallback: F) -> PeekRouter<P, T, F>
pub fn with_fallback<F>(self, fallback: F) -> PeekRouter<P, T, F>
Attach a fallback Service.
§impl<P, T, F> PeekRouter<P, T, F>
impl<P, T, F> PeekRouter<P, T, F>
pub fn maybe_with_peek_timeout(
self,
peek_timeout: Option<Duration>,
) -> PeekRouter<P, T, F>
pub fn maybe_with_peek_timeout( self, peek_timeout: Option<Duration>, ) -> PeekRouter<P, T, F>
Set the maximum time spent peeking into the input.
pub fn maybe_set_peek_timeout(
&mut self,
peek_timeout: Option<Duration>,
) -> &mut PeekRouter<P, T, F>
pub fn maybe_set_peek_timeout( &mut self, peek_timeout: Option<Duration>, ) -> &mut PeekRouter<P, T, F>
Set the maximum time spent peeking into the input.
pub fn with_peek_timeout(self, peek_timeout: Duration) -> PeekRouter<P, T, F>
pub fn with_peek_timeout(self, peek_timeout: Duration) -> PeekRouter<P, T, F>
Set the maximum time spent peeking into the input.
pub fn set_peek_timeout(
&mut self,
peek_timeout: Duration,
) -> &mut PeekRouter<P, T, F>
pub fn set_peek_timeout( &mut self, peek_timeout: Duration, ) -> &mut PeekRouter<P, T, F>
Set the maximum time spent peeking into the input.
pub fn without_peek_timeout(self) -> PeekRouter<P, T, F>
pub fn without_peek_timeout(self) -> PeekRouter<P, T, F>
Set the maximum time spent peeking into the input.
pub fn unset_peek_timeout(&mut self) -> &mut PeekRouter<P, T, F>
pub fn unset_peek_timeout(&mut self) -> &mut PeekRouter<P, T, F>
Set the maximum time spent peeking into the input.
pub fn with_max_peek_size(
self,
max_peek_size: NonZero<usize>,
) -> PeekRouter<P, T, F>
pub fn with_max_peek_size( self, max_peek_size: NonZero<usize>, ) -> PeekRouter<P, T, F>
Set the byte limit for peeking; this does not impose a time limit.
pub fn set_max_peek_size(
&mut self,
max_peek_size: NonZero<usize>,
) -> &mut PeekRouter<P, T, F>
pub fn set_max_peek_size( &mut self, max_peek_size: NonZero<usize>, ) -> &mut PeekRouter<P, T, F>
Set the byte limit for peeking; this does not impose a time limit.
pub fn with_peek_read_chunk_size(
self,
peek_read_chunk_size: NonZero<usize>,
) -> PeekRouter<P, T, F>
pub fn with_peek_read_chunk_size( self, peek_read_chunk_size: NonZero<usize>, ) -> PeekRouter<P, T, F>
Set the maximum number of bytes requested per read.
pub fn set_peek_read_chunk_size(
&mut self,
peek_read_chunk_size: NonZero<usize>,
) -> &mut PeekRouter<P, T, F>
pub fn set_peek_read_chunk_size( &mut self, peek_read_chunk_size: NonZero<usize>, ) -> &mut PeekRouter<P, T, F>
Set the maximum number of bytes requested per read.
§impl<T> PeekRouter<(), T>
impl<T> PeekRouter<(), T>
pub fn from_prefix(
prefix: &'static [u8],
acceptor: T,
) -> PeekRouter<impl Clone + Fn(&[u8]), T>
pub fn from_prefix( prefix: &'static [u8], acceptor: T, ) -> PeekRouter<impl Clone + Fn(&[u8]), T>
Create a router matching a fixed prefix.
Peeking is limited to the prefix length unless overridden.
§Panics
Panics when prefix is empty.
Trait Implementations§
§impl<P, T, F> Clone for PeekRouter<P, T, F>
impl<P, T, F> Clone for PeekRouter<P, T, F>
§fn clone(&self) -> PeekRouter<P, T, F>
fn clone(&self) -> PeekRouter<P, T, F>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<P, T, F> Debug for PeekRouter<P, T, F>
impl<P, T, F> Debug for PeekRouter<P, T, F>
§impl<PeekableInput, Output, P, T, F> Service<PeekableInput> for PeekRouter<P, T, F>where
PeekableInput: PeekIoProvider,
<PeekableInput as PeekIoProvider>::PeekIo: Unpin,
Output: Send + 'static,
P: Fn(&[u8]) -> PeekVerdict<()> + Send + Sync + 'static,
T: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<T as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
F: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<F as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
impl<PeekableInput, Output, P, T, F> Service<PeekableInput> for PeekRouter<P, T, F>where
PeekableInput: PeekIoProvider,
<PeekableInput as PeekIoProvider>::PeekIo: Unpin,
Output: Send + 'static,
P: Fn(&[u8]) -> PeekVerdict<()> + Send + Sync + 'static,
T: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<T as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
F: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<F as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
§async fn serve(
&self,
input: PeekableInput,
) -> Result<<PeekRouter<P, T, F> as Service<PeekableInput>>::Output, <PeekRouter<P, T, F> as Service<PeekableInput>>::Error>
async fn serve( &self, input: PeekableInput, ) -> Result<<PeekRouter<P, T, F> as Service<PeekableInput>>::Output, <PeekRouter<P, T, F> as Service<PeekableInput>>::Error>
§fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
Auto Trait Implementations§
impl<P, T, F> Freeze for PeekRouter<P, T, F>
impl<P, T, F> RefUnwindSafe for PeekRouter<P, T, F>
impl<P, T, F> Send for PeekRouter<P, T, F>
impl<P, T, F> Sync for PeekRouter<P, T, F>
impl<P, T, F> Unpin for PeekRouter<P, T, F>
impl<P, T, F> UnsafeUnpin for PeekRouter<P, T, F>
impl<P, T, F> UnwindSafe for PeekRouter<P, T, F>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<S, Input, Connection> ConnectorService<Input> for Swhere
S: Service<Input, Output = EstablishedClientConnection<Connection, Input>>,
<S as Service<Input>>::Error: Into<ConnectionError>,
Connection: Send + ExtensionsRef,
impl<S, Input, Connection> ConnectorService<Input> for Swhere
S: Service<Input, Output = EstablishedClientConnection<Connection, Input>>,
<S as Service<Input>>::Error: Into<ConnectionError>,
Connection: Send + ExtensionsRef,
§type Connection = Connection
type Connection = Connection
ConnectorService§fn connect(
&self,
input: Input,
) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, ConnectionError>> + Send
fn connect( &self, input: Input, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, ConnectionError>> + Send
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more