[][src]Crate socket_collection

Overview

The goal of this crate is to provide a collection of async sockets which can be used out of the box with mio event loop. Currently the crate exposes UDP and TCP sockets: UdpSock and TcpSock respectively. The socket behavior is very specific for p2p and Crust crates. We aim to make the sockets easy to use and reduce boilerplate code. The sockets buffer incoming/outgoing data, implement message serialization and encryption, the user of the stream based sockets don't need to worry about message boundaries, each message has a priority, number etc.

Structs

SocketConfig

Configures socket behavior.

TcpSock

TCP socket which by default is uninitialized. Asynchronous TCP socket wrapper with some specific behavior to our use cases:

UdpSock

Asynchronous UDP socket wrapper with some specific behavior to our use cases:

Enums

DecryptContext

Simplifies decryption by holding the necessary context - keys to decrypt data. Allows "null" decryption where data is only deserialized. See: null object pattern.

EncryptContext

Simplifies encryption by holding the necessary context - encryption keys. Allows "null" encryption where data is only serialized. See: null object pattern.

Socket

Protocol agnostic socket that wraps UdpSock and TcpSock.

SocketError

Common module specific error

Constants

DEFAULT_MAX_MSG_AGE_SECS

Maximum age of a message waiting to be sent. If a message is older, the queue is dropped.

DEFAULT_MAX_PAYLOAD_SIZE

Don't allow packets bigger than this value.

DEFAULT_MSG_DROP_PRIORITY

Minimum priority for droppable messages. Messages with lower values will never be dropped.

Type Definitions

Priority

Priority of a message to be sent by Crust. A lower value means a higher priority, so Priority 0 is the highest one. Low-priority messages will be preempted if need be to allow higher priority messages through. Messages with a value >= MSG_DROP_PRIORITY will even be dropped, if bandwidth is insufficient.

Res

Result type specialised for this crate