Skip to main content

Protocol

Trait Protocol 

Source
pub trait Protocol:
    Send
    + Sync
    + 'static {
    type ProtoError: Send + 'static;
    type Event: Clone + Send + 'static;

    // Required methods
    fn encode_request(
        id: u64,
        method: &str,
        params: Value,
        session_id: Option<&str>,
    ) -> Result<String>;
    fn decode_frame(text: &str) -> Decoded<Self::ProtoError, Self::Event>;
    fn closed_error() -> Self::ProtoError;
}
Expand description

Protocol adapter: the dialect-specific framing/typing that the shared transport delegates to. CDP and BiDi each implement this; everything else (socket, tasks, correlation, timeouts, lifecycle) is shared.

Required Associated Types§

Source

type ProtoError: Send + 'static

Per-reply protocol error type (e.g. CdpError / BidiError).

Source

type Event: Clone + Send + 'static

Broadcast event type delivered to subscribers.

Required Methods§

Source

fn encode_request( id: u64, method: &str, params: Value, session_id: Option<&str>, ) -> Result<String>

Serialize an outbound request to the wire text. session_id carries the CDP flat-session id; BiDi ignores it.

Source

fn decode_frame(text: &str) -> Decoded<Self::ProtoError, Self::Event>

Decode an inbound text frame into a Decoded outcome.

Source

fn closed_error() -> Self::ProtoError

Build the protocol’s “connection closed” error used to fail pending requests when the reader task exits (socket close / I/O error). This is what makes a disconnect surface as the protocol’s typed error instead of silently dropping the oneshot.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§