pub trait RecvFrame {
    // Required methods
    fn recv_frame(&mut self) -> Result<Vec<u8>, Error>;
    fn recv_raw(&mut self, len: usize) -> Result<Vec<u8>, Error>;

    // Provided method
    fn recv_routed(&mut self) -> Result<RoutedFrame, Error> { ... }
}
Expand description

Frame receiving type which is able to parse raw data (streamed or framed by an underlying overlaid protocol such as ZMQ, HTTP, Websocket).

Required Methods§

source

fn recv_frame(&mut self) -> Result<Vec<u8>, Error>

Receive a single frame of data structured as a byte string. The frame contains LNP framing prefix, which is used by upstream session-level protocols.

Errors

Returns only Error::SocketIo if the overlaid protocol errors with I/O error type

source

fn recv_raw(&mut self, len: usize) -> Result<Vec<u8>, Error>

Try to receive len number of bytes and pack them as a frame. The actual amount of bytes received may differ for some protocols, like ZMQ, so the function should be used with caution!

Errors

Returns only Error::SocketIo if the overlaid protocol errors with I/O error type

Provided Methods§

source

fn recv_routed(&mut self) -> Result<RoutedFrame, Error>

Receive frame like with RecvFrame::recv_frame, but only originating from the specified remote address.

Returns

Tuple, consisting of two byte strings:

  • Received frame
  • Source of the frame (i.e. some id of the remote node that sent this frame). The id is specific for the underlying overlaid protocol.
Errors

Returns only Error::SocketIo if the overlaid protocol errors with I/O error type

Panics

Default implementation panics, since most of the framing protocols do not support multipeer sockets and RecvFrame::recv_frame must be used instead (currently only ZMQ-based connections support this operation)

Implementations on Foreign Types§

source§

impl RecvFrame for TcpStream

source§

fn recv_frame(&mut self) -> Result<Vec<u8>, Error>

source§

fn recv_raw(&mut self, len: usize) -> Result<Vec<u8>, Error>

Implementors§

source§

impl RecvFrame for internet2::transport::unencrypted::Stream

source§

impl RecvFrame for WrappedSocket

source§

impl<const LEN_SIZE: usize> RecvFrame for internet2::transport::encrypted::Stream<LEN_SIZE>