Struct WebSocketRelayEventService
pub struct WebSocketRelayEventService<S = MirrorService> { /* private fields */ }http and std and ws only.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§
§impl<S> WebSocketRelayEventService<S>
impl<S> WebSocketRelayEventService<S>
pub fn new(middleware: S) -> WebSocketRelayEventService<S>
pub fn new(middleware: S) -> WebSocketRelayEventService<S>
Create a new WebSocketRelayEventService.
pub fn with_close_handshake_timeout(
self,
timeout: Duration,
) -> WebSocketRelayEventService<S>
pub fn with_close_handshake_timeout( self, timeout: Duration, ) -> WebSocketRelayEventService<S>
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.
pub fn set_close_handshake_timeout(
&mut self,
timeout: Duration,
) -> &mut WebSocketRelayEventService<S>
pub fn set_close_handshake_timeout( &mut self, timeout: Duration, ) -> &mut WebSocketRelayEventService<S>
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§
§impl<S> Clone for WebSocketRelayEventService<S>where
S: Clone,
impl<S> Clone for WebSocketRelayEventService<S>where
S: Clone,
§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 more§impl<S> Debug for WebSocketRelayEventService<S>where
S: Debug,
impl<S> Debug for WebSocketRelayEventService<S>where
S: Debug,
§impl<S, Ingress, Egress> Service<BridgeIo<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput>,
<S as Service<WebSocketRelayEventInput>>::Output: Into<WebSocketRelayEventOutput>,
<S as Service<WebSocketRelayEventInput>>::Error: Into<Box<dyn Error + Sync + Send>>,
Ingress: Io + Unpin + ExtensionsRef,
Egress: Io + Unpin + ExtensionsRef,
impl<S, Ingress, Egress> Service<BridgeIo<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput>,
<S as Service<WebSocketRelayEventInput>>::Output: Into<WebSocketRelayEventOutput>,
<S as Service<WebSocketRelayEventInput>>::Error: Into<Box<dyn Error + Sync + Send>>,
Ingress: Io + Unpin + ExtensionsRef,
Egress: Io + Unpin + ExtensionsRef,
§type Error = Infallible
type Error = Infallible
§async fn serve(
&self,
bridge: BridgeIo<Ingress, Egress>,
) -> Result<<WebSocketRelayEventService<S> as Service<BridgeIo<Ingress, Egress>>>::Output, <WebSocketRelayEventService<S> as Service<BridgeIo<Ingress, Egress>>>::Error>
async fn serve( &self, bridge: BridgeIo<Ingress, Egress>, ) -> Result<<WebSocketRelayEventService<S> as Service<BridgeIo<Ingress, Egress>>>::Output, <WebSocketRelayEventService<S> as Service<BridgeIo<Ingress, Egress>>>::Error>
§fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
§impl<S, Ingress, Egress> Service<WebSocketBridge<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput>,
<S as Service<WebSocketRelayEventInput>>::Output: Into<WebSocketRelayEventOutput>,
<S as Service<WebSocketRelayEventInput>>::Error: Into<Box<dyn Error + Sync + Send>>,
Ingress: WebSocketIo,
Egress: WebSocketIo,
impl<S, Ingress, Egress> Service<WebSocketBridge<Ingress, Egress>> for WebSocketRelayEventService<S>where
S: Service<WebSocketRelayEventInput>,
<S as Service<WebSocketRelayEventInput>>::Output: Into<WebSocketRelayEventOutput>,
<S as Service<WebSocketRelayEventInput>>::Error: Into<Box<dyn Error + Sync + Send>>,
Ingress: WebSocketIo,
Egress: WebSocketIo,
§type Error = Infallible
type Error = Infallible
§async fn serve(
&self,
__arg1: WebSocketBridge<Ingress, Egress>,
) -> Result<<WebSocketRelayEventService<S> as Service<WebSocketBridge<Ingress, Egress>>>::Output, <WebSocketRelayEventService<S> as Service<WebSocketBridge<Ingress, Egress>>>::Error>
async fn serve( &self, __arg1: WebSocketBridge<Ingress, Egress>, ) -> Result<<WebSocketRelayEventService<S> as Service<WebSocketBridge<Ingress, Egress>>>::Output, <WebSocketRelayEventService<S> as Service<WebSocketBridge<Ingress, Egress>>>::Error>
§fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
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§
§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