pub struct WebSocketRelayEventService<S = MirrorService> { /* private fields */ }Expand description
A WebSocket MITM relay that exposes every message observable through the high-level WebSocket protocol API to its middleware.
Like WebSocketRelayService, this accepts either raw BridgeIo or an
established WebSocketBridge. Use WebSocketRelayIoService when
message-level layers must run between protocol construction and this relay.
Unlike WebSocketRelayService, this service exposes ping, pong and close
events. Control messages remain owned by the relay: a ping is acknowledged
locally and produces an unsolicited pong heartbeat on the opposite
connection, while other pongs are not forwarded. An incoming close always
starts coordinated shutdown.
Middleware is processed independently per direction. Its future can be cancelled when either peer starts closing, so it must be cancel-safe. Data received after shutdown starts is discarded rather than exposed, and a failure to send middleware-produced data terminates the relay.
Implementations§
Source§impl<S> WebSocketRelayEventService<S>
impl<S> WebSocketRelayEventService<S>
Sourcepub fn new(middleware: S) -> Self
pub fn new(middleware: S) -> Self
Create a new WebSocketRelayEventService.
Sourcepub fn with_close_handshake_timeout(self, timeout: Duration) -> Self
pub fn with_close_handshake_timeout(self, timeout: Duration) -> Self
Set how long the relay waits for both peers to finish a coordinated close handshake before dropping the connections.
The default is five seconds. Both connections and their relay state remain alive until the handshake finishes or this timeout expires.
Sourcepub fn set_close_handshake_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_close_handshake_timeout(&mut self, timeout: Duration) -> &mut Self
Set how long the relay waits for both peers to finish a coordinated close handshake before dropping the connections.
The default is five seconds. Both connections and their relay state remain alive until the handshake finishes or this timeout expires.
Trait Implementations§
Source§impl<S: Clone> Clone for WebSocketRelayEventService<S>
impl<S: Clone> Clone for WebSocketRelayEventService<S>
Source§fn clone(&self) -> WebSocketRelayEventService<S>
fn clone(&self) -> WebSocketRelayEventService<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S: Debug> Debug for WebSocketRelayEventService<S>
impl<S: Debug> Debug for WebSocketRelayEventService<S>
Source§impl<S, Ingress, Egress> Service<BridgeIo<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput, Output: Into<WebSocketRelayEventOutput>, Error: Into<BoxError>>,
Ingress: Io + Unpin + ExtensionsRef,
Egress: Io + Unpin + ExtensionsRef,
impl<S, Ingress, Egress> Service<BridgeIo<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput, Output: Into<WebSocketRelayEventOutput>, Error: Into<BoxError>>,
Ingress: Io + Unpin + ExtensionsRef,
Egress: Io + Unpin + ExtensionsRef,
Source§impl<S, Ingress, Egress> Service<WebSocketBridge<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput, Output: Into<WebSocketRelayEventOutput>, Error: Into<BoxError>>,
Ingress: WebSocketIo,
Egress: WebSocketIo,
impl<S, Ingress, Egress> Service<WebSocketBridge<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput, Output: Into<WebSocketRelayEventOutput>, Error: Into<BoxError>>,
Ingress: WebSocketIo,
Egress: WebSocketIo,
Auto Trait Implementations§
impl<S> Freeze for WebSocketRelayEventService<S>where
S: Freeze,
impl<S> RefUnwindSafe for WebSocketRelayEventService<S>where
S: RefUnwindSafe,
impl<S> Send for WebSocketRelayEventService<S>where
S: Send,
impl<S> Sync for WebSocketRelayEventService<S>where
S: Sync,
impl<S> Unpin for WebSocketRelayEventService<S>where
S: Unpin,
impl<S> UnsafeUnpin for WebSocketRelayEventService<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for WebSocketRelayEventService<S>where
S: UnwindSafe,
Blanket Implementations§
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,
Source§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,
Source§type Connection = Connection
type Connection = Connection
ConnectorServiceSource§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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer