[][src]Crate pea2pea

pea2pea is a P2P library designed with the following use cases in mind:

  • simple and quick creation of P2P networks
  • testing/verifying network protocols
  • benchmarking and stress-testing P2P nodes (or other network entities)
  • substituting other, "heavier" nodes in local network tests

Structs

Connection

An object dedicated to performing writes to the stream

ConnectionReader

An object dedicated to performing reads from a connection's stream.

HandshakeSetup

An object dedicated to handling connection handshakes.

Node

The central object responsible for handling all the connections.

NodeConfig

The node's configuration.

Enums

Topology

The way in which nodes are connected to each other; used in connect_nodes.

Traits

ContainsNode

A trait for objects containing a Node; it is required to implement protocols.

Handshaking

This protocol can be used to specify and enable network handshakes. Upon establishing a connection, both sides will need to adhere to the specified handshake rules in order to finalize the connection and be able to transmit any messages. Note: if not implemented, the nodes unconditionally mark their connections as handshaken.

Messaging

This protocol can be used to specify and enable messaging, i.e. handling of inbound messages and replying to them. If handshaking is enabled too, it goes into force only after the handshake has been concluded.

Functions

connect_nodes

Connects the provided list of nodes in order to form the given Topology.

Type Definitions

HandshakeState

A trait object containing handshake state.

InboundMessage

The type transmitted using the InboundMessages sender.

ReadingClosure

The closure used to receive inbound messages from every connection.