pub trait SendFrame {
// Required methods
fn send_frame(&mut self, frame: &[u8]) -> Result<usize, Error>;
fn send_raw(&mut self, raw_frame: &[u8]) -> Result<usize, Error>;
// Provided method
fn send_routed(
&mut self,
_source: &[u8],
_route: &[u8],
_address: &[u8],
_data: &[u8]
) -> Result<usize, Error> { ... }
}
Expand description
Frame sending type which is able to compose frame with a given raw data and send it via an underlying overlaid protocol such as ZMQ, HTTP, Websocket.
Required Methods§
sourcefn send_frame(&mut self, frame: &[u8]) -> Result<usize, Error>
fn send_frame(&mut self, frame: &[u8]) -> Result<usize, Error>
Sends a single frame of data structured as a byte string. The frame must
already contain LNP framing prefix with size data. The function must
check that the provided data frame length is below the limit defined
with MAX_FRAME_SIZE
constant if a tcp connection is used.
Returns
In case of success, number of bytes send (NB: this is larger than the
message payload size and is equal to the size of the provided frame
argument)
Errors
Error::SocketIo
if the overlaid protocol errors with I/O error typeError::OversizedFrame
if the provided data length exceedsMAX_FRAME_SIZE
and a tcp connection is used
sourcefn send_raw(&mut self, raw_frame: &[u8]) -> Result<usize, Error>
fn send_raw(&mut self, raw_frame: &[u8]) -> Result<usize, Error>
Sends a single frame of data structured as a byte string. The frame must already contain LNP framing prefix with size data.
NB: Unlike SendFrame::send_frame
, this function does not check
that the provided data frame length is below the limit defined with
MAX_FRAME_SIZE
constant.
Returns
In case of success, number of bytes send (NB: this is larger than the
message payload size and is equal to the size of the provided
raw_frame
argument)
Errors
Error::SocketIo
if the overlaid protocol errors with I/O error type
Provided Methods§
sourcefn send_routed(
&mut self,
_source: &[u8],
_route: &[u8],
_address: &[u8],
_data: &[u8]
) -> Result<usize, Error>
fn send_routed(
&mut self,
_source: &[u8],
_route: &[u8],
_address: &[u8],
_data: &[u8]
) -> Result<usize, Error>
Sends a single frame of data structured as a byte string to a specific
receiver with remote_id
. Function works like RecvFrame::recv_frame
and is used for the underlying protocols supporting multipeer
connectivity. The frame must already contain LNP framing prefix with
size data.
Returns
In case of success, number of bytes send (NB: this is larger than the
message payload size and is equal to the size of the provided frame
argument)
Errors
Error::SocketIo
if the overlaid protocol errors with I/O error type
Panics
Default implementation panics, since the most of framing protocols do
not support multipeer sockets and SendFrame::send_frame
must be
used instead (currently only ZMQ-based connections support this
operation)