Trait vapcore_network::NetworkContext[][src]

pub trait NetworkContext {
    fn send(
        &self,
        peer: PeerId,
        packet_id: PacketId,
        data: Vec<u8>
    ) -> Result<(), Error>;
fn send_protocol(
        &self,
        protocol: ProtocolId,
        peer: PeerId,
        packet_id: PacketId,
        data: Vec<u8>
    ) -> Result<(), Error>;
fn respond(&self, packet_id: PacketId, data: Vec<u8>) -> Result<(), Error>;
fn disable_peer(&self, peer: PeerId);
fn disconnect_peer(&self, peer: PeerId);
fn is_expired(&self) -> bool;
fn register_timer(
        &self,
        token: TimerToken,
        delay: Duration
    ) -> Result<(), Error>;
fn peer_client_version(&self, peer: PeerId) -> ClientVersion;
fn session_info(&self, peer: PeerId) -> Option<SessionInfo>;
fn protocol_version(&self, protocol: ProtocolId, peer: PeerId) -> Option<u8>;
fn subprotocol_name(&self) -> ProtocolId;
fn is_reserved_peer(&self, peer: PeerId) -> bool;
fn payload_soft_limit(&self) -> usize; }

IO access point. This is passed to all IO handlers and provides an interface to the IO subsystem.

Required methods

fn send(
    &self,
    peer: PeerId,
    packet_id: PacketId,
    data: Vec<u8>
) -> Result<(), Error>
[src]

Send a packet over the network to another peer.

fn send_protocol(
    &self,
    protocol: ProtocolId,
    peer: PeerId,
    packet_id: PacketId,
    data: Vec<u8>
) -> Result<(), Error>
[src]

Send a packet over the network to another peer using specified protocol.

fn respond(&self, packet_id: PacketId, data: Vec<u8>) -> Result<(), Error>[src]

Respond to a current network message. Panics if no there is no packet in the context. If the session is expired returns nothing.

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

Disconnect a peer and prevent it from connecting again.

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

Disconnect peer. Reconnect can be attempted later.

fn is_expired(&self) -> bool[src]

Check if the session is still active.

fn register_timer(
    &self,
    token: TimerToken,
    delay: Duration
) -> Result<(), Error>
[src]

Register a new IO timer. ‘IoHandler::timeout’ will be called with the token.

fn peer_client_version(&self, peer: PeerId) -> ClientVersion[src]

Returns peer identification string

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

Returns information on p2p session

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

Returns max version for a given protocol.

fn subprotocol_name(&self) -> ProtocolId[src]

Returns this object’s subprotocol name.

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

Returns whether the given peer ID is a reserved peer.

fn payload_soft_limit(&self) -> usize[src]

Returns the size the payload shouldn’t exceed

Loading content...

Implementations on Foreign Types

impl<'a, T: ?Sized> NetworkContext for &'a T where
    T: NetworkContext
[src]

Loading content...

Implementors

Loading content...