# Trait ethcore_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>;
    }

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>)`

Send a packet to a specific peer.

### `fn respond(&self, packet_id: u8, packet_body: Vec<u8>)`

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

### `fn disconnect_peer(&self, peer: PeerId)`

Disconnect a peer.

### `fn disable_peer(&self, peer: PeerId)`

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

### `fn protocol_version(&self, peer: PeerId) -> Option<u8>`

Get a peer's protocol version.

### `fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>`

Persistent peer id

## Implementors

- `impl<'a> IoContext for NetworkContext<'a>`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)