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§
Sourcetype ProtoError: Send + 'static
type ProtoError: Send + 'static
Per-reply protocol error type (e.g. CdpError / BidiError).
Required Methods§
Sourcefn encode_request(
id: u64,
method: &str,
params: Value,
session_id: Option<&str>,
) -> Result<String>
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.
Sourcefn decode_frame(text: &str) -> Decoded<Self::ProtoError, Self::Event>
fn decode_frame(text: &str) -> Decoded<Self::ProtoError, Self::Event>
Decode an inbound text frame into a Decoded outcome.
Sourcefn closed_error() -> Self::ProtoError
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".