Skip to main content

PeekIoProvider

Trait PeekIoProvider 

pub trait PeekIoProvider: Send + 'static {
    type PeekIo: Io;
    type PeekEgressIo: Io;
    type Mapped<PeekedIo: Io, PeekedEgressIo: Io>: Send + 'static;

    // Required methods
    fn peek_ios_mut(
        &mut self,
    ) -> (&mut Self::PeekIo, Option<&mut Self::PeekEgressIo>);
    fn map_peek_io<PeekedIo, PeekedEgressIo, F, G>(
        self,
        map: F,
        map_egress: G,
    ) -> Self::Mapped<PeekedIo, PeekedEgressIo>
       where PeekedIo: Io,
             PeekedEgressIo: Io,
             F: FnOnce(Self::PeekIo) -> PeekedIo,
             G: FnOnce(Self::PeekEgressIo) -> PeekedEgressIo;
}
Available on crate feature std only.
Expand description

A higher level trait that can be used by services which wish to peek into I/O, often as part of Deep Protocol Inspections (DPI).

It is implemented for any Io, returning itself as ingress and reporting no egress. BridgeIo also implements it, exposing its first element as the ingress and its second element as the egress.

Required Associated Types§

type PeekIo: Io

The ingress type that can be peeked.

type PeekEgressIo: Io

The egress type that can be peeked, NoPeekEgress when there is none.

type Mapped<PeekedIo: Io, PeekedEgressIo: Io>: Send + 'static

The mapped Self type produced as a result of mapping the PeekIo and PeekEgressIo types.

Required Methods§

fn peek_ios_mut( &mut self, ) -> (&mut Self::PeekIo, Option<&mut Self::PeekEgressIo>)

Retrieve mutable references to the peekable ingress and, if there is one, the peekable egress.

fn map_peek_io<PeekedIo, PeekedEgressIo, F, G>( self, map: F, map_egress: G, ) -> Self::Mapped<PeekedIo, PeekedEgressIo>
where PeekedIo: Io, PeekedEgressIo: Io, F: FnOnce(Self::PeekIo) -> PeekedIo, G: FnOnce(Self::PeekEgressIo) -> PeekedEgressIo,

Once peeking is finished one can reproduce self by mapping the peeked ingress and egress, usually with the peeked data in-memory as prefix.

map_egress is only called when there is an egress.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl<Ingress, Egress> PeekIoProvider for BridgeIo<Ingress, Egress>
where Ingress: Io, Egress: Io,

§

type PeekIo = Ingress

§

type PeekEgressIo = Egress

§

type Mapped<PeekedIngress: Io, PeekedEgress: Io> = BridgeIo<PeekedIngress, PeekedEgress>

§

impl<T> PeekIoProvider for T
where T: Io,

§

type PeekIo = T

§

type PeekEgressIo = NoPeekEgress

§

type Mapped<PeekedIo: Io, PeekedEgressIo: Io> = PeekedIo