29 releases (6 breaking)

new 0.7.1 Nov 22, 2024
0.6.1 Oct 11, 2024
0.2.0 Jul 31, 2024

#1222 in Web programming

Download history 1428/week @ 2024-08-02 464/week @ 2024-08-09 178/week @ 2024-08-16 215/week @ 2024-08-23 181/week @ 2024-08-30 147/week @ 2024-09-06 438/week @ 2024-09-13 250/week @ 2024-09-20 94/week @ 2024-09-27 108/week @ 2024-10-04 219/week @ 2024-10-11 60/week @ 2024-10-18 160/week @ 2024-10-25 140/week @ 2024-11-01 69/week @ 2024-11-08 124/week @ 2024-11-15

517 downloads per month
Used in 4 crates

Apache-2.0

33KB
526 lines

protosocket-connection

protosocket-connection provides a flexible, asynchronous TCP connection handler. It's designed to efficiently manage bidirectional, message-oriented TCP streams with customizable serialization and deserialization.

Key Features

  • Low abstraction - no http or higher level constructs
  • Asynchronous I/O using mio via tokio
  • Customizable message types through ConnectionBindings
  • Efficient buffer management and flexible error handling

Flow Diagrams

The poll() function on connection.rs controls the lifecycle of the entire connection. You're recommended to read individual comments on the code to understand the flow, but below is a sequence diagram to get you started:

sequenceDiagram
    participant P as Poll
    participant IS as Inbound Socket
    participant D as Deserializer
    participant R as Reactor
    participant S as Serializer
    participant OS as Outbound Socket

    P->>IS: Read from inbound socket
    IS->>D: Raw data
    D->>P: Deserialize inbound messages
    P->>R: Submit inbound messages
    R-->>P: Process messages
    P->>S: Prepare and serialize outbound messages
    S->>P: Serialized outbound bytes
    P->>OS: Write to outbound socket

Dependencies

~4–12MB
~131K SLoC