pub trait Protocol: Send + Sync {
// Required methods
fn subprotocol(&self) -> &str;
fn encode(&self, command: &Command) -> Result<Vec<u8>, Error>;
fn decode(&self, payload: &[u8]) -> Result<Incoming, Error>;
}Expand description
Translates between Action Cable commands and the bytes on the wire. It is the seam where an Action Cable protocol plugs in.
One protocol speaks one subprotocol. A client offers every protocol it was given and speaks the one the server picks, so supporting a new protocol means adding one rather than replacing the list.
Required Methods§
Sourcefn subprotocol(&self) -> &str
fn subprotocol(&self) -> &str
The name this protocol negotiates under.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".