[][src]Crate tcp_typed

A wrapper around platform TCP socket APIs that leverages the type system to ensure correct usage.

Crates.ioRepo

It's quite easy to accidentally misuse the Berkeley sockets or similar APIs, resulting in ECONNRESET/EPIPE/etc, data being lost on close, and potential hangs from non-exhaustive collection of events given edge-triggered notifications.

This library aims to make it impossible to misuse in non-unsafe code.

If you ever see a connection reset / ECONNRESET, EPIPE, data being lost on close, or panic, then it is a bug in this library! Please file an issue with as much info as possible.

It's designed to be used in conjunction with an implementer of the Notifier trait – for example notifier. As long as the Notifier contract is fulfilled, then this library will collect all relevent events (connected, data in, data available to be written, remote closed, bytes acked, connection errors) upon each edge-triggered notification.

Note

Currently doesn't support Windows.

Structs

Closing
Connected
Connectee
ConnecteeLocalClosed
Connecter
ConnecterLocalClosed
Listener
LocalClosed
RemoteClosed
SocketForwardee
SocketForwarder

Enums

ClosingPoll
ConnectedPoll
ConnecteeLocalClosedPoll
ConnecteePoll
ConnecterLocalClosedPoll
ConnecterPoll
Connection

Essentially a dynamically-typed connection, wrapping all of the individual states in an enum and providing methods that are available or not dynamically (by returning an Option<impl FnOnce(..)>).

LocalClosedPoll
RemoteClosedPoll

Traits

Notifier

Implementers and users are responsible for calling fn poll(self, &impl Notifier) on Connections or the states (Connecter, Connectee, ConnecterLocalClosed, etc) as instructed by calls made to it via this trait.

Functions

socket_forwarder