pub trait TransportSink: Send {
// Required methods
fn send<'a>(
&'a mut self,
frame: String,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>;
fn ping<'a>(
&'a mut self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>;
fn pong<'a>(
&'a mut self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>;
fn close<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>;
}Expand description
The write half of a transport: sends one complete OCPP-J text frame at a time.
Implementations own only framing (e.g. WebSocket masking) - Client never sees
anything but whole frames and keepalive events.
Methods return a boxed future (the shape #[async_trait] expands to, written by hand)
rather than using async fn in the trait, so Box<dyn TransportSink> stays usable - this
crate has no dependency on the async-trait crate itself, only on alloc.
Required Methods§
fn send<'a>( &'a mut self, frame: String, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>
Sourcefn ping<'a>(
&'a mut self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>
fn ping<'a>( &'a mut self, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>
Send a ping carrying payload as its application data. Client puts a correlation
token there and matches it against the echoed payload of the pong that comes back, so
implementations must transmit it verbatim instead of sending an empty ping.
Sourcefn pong<'a>(
&'a mut self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>
fn pong<'a>( &'a mut self, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>
Send a pong carrying payload. When replying to a received ping, RFC 6455 requires
this to be that ping’s application data verbatim - the read loop passes it straight
through from TransportEvent::Ping.
fn close<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'a>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".