#client-server #p2p #server #client #networking

netty-rs

Netty-rs allows exposes a simple-to-use API used to create stateful application level network protocols as both a client or server

1 unstable release

0.1.0 Apr 18, 2021

#253 in #p2p

22 downloads per month

MIT/Apache

46KB
652 lines

Netty-rs

Netty-rs allows exposes a simple-to-use API used to create stateful application level network protocols as both a client or server.

Motivation

When implementing p2p applications I found myself implementing the same TCP constructs over and over again in order to be able to implement a custom message passing protocol that allowed for multiplexing different peers and replying to messages. This crate is an attempt to generalize the solution to this problem.

API

Netty-rs allows requires consumers specify how to handle messages in different circumstances. Whenever specifying this the same API is used by using Connection. This very simple API allows consumers to specify restful protocols of varying complexity. Each message-and-reply chain is in their own channel which does not and is not impacted by messages sent or received in other message-and-reply chains.

The situations where how to handle messages need to be specified are:

  1. When a consumer sends a message it can choose to wait for a reply and handle it in a custom way.
  2. When acting as a server consumers need to specify how to handshake with new connections, which allows custom authentication of clients among any other handshake related action.
  3. When acting as a server consumers need to specify how to handle non-reply messages from connections that have already been authenticated.

The main API is accessed through the Networker struct.

Netty-rs uses the DirectoryService trait in order to allow consumers to either implement their own directory service for example a DNS or use the SimpleDirectoryService struct that implements this trait.

See the docs for further documentation and an example.

Dependencies

~4–15MB
~161K SLoC