Trait vapcore_light::net::IoContext[][src]

pub trait IoContext {
    fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>);
fn respond(&self, packet_id: u8, packet_body: Vec<u8>);
fn disconnect_peer(&self, peer: PeerId);
fn disable_peer(&self, peer: PeerId);
fn protocol_version(&self, peer: PeerId) -> Option<u8>;
fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>;
fn is_reserved_peer(&self, peer: PeerId) -> bool; }

An I/O context which allows sending and receiving packets as well as disconnecting peers. This is used as a generalization of the portions of a p2p network which the light protocol structure makes use of.

Required methods

fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>)[src]

Send a packet to a specific peer.

fn respond(&self, packet_id: u8, packet_body: Vec<u8>)[src]

Respond to a peer’s message. Only works if this context is a byproduct of a packet handler.

fn disconnect_peer(&self, peer: PeerId)[src]

Disconnect a peer.

fn disable_peer(&self, peer: PeerId)[src]

Disable a peer – this is a disconnect + a time-out.

fn protocol_version(&self, peer: PeerId) -> Option<u8>[src]

Get a peer’s protocol version.

fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>[src]

Persistent peer id

fn is_reserved_peer(&self, peer: PeerId) -> bool[src]

Whether given peer id is reserved peer

Loading content...

Implementors

impl<T: ?Sized> IoContext for T where
    T: NetworkContext
[src]

Loading content...