#protobuf #performance #service

protosocket

Message-oriented nonblocking tcp stream

43 releases (11 breaking)

1.0.0-pre.3 Feb 17, 2026
1.0.0-pre.1 Dec 20, 2025
0.12.1 Nov 14, 2025
0.8.0 Feb 12, 2025
0.2.0 Jul 31, 2024

#242 in Web programming

Download history 237/week @ 2025-11-14 243/week @ 2025-11-21 107/week @ 2025-11-28 207/week @ 2025-12-05 290/week @ 2025-12-12 81/week @ 2025-12-19 14/week @ 2025-12-26 105/week @ 2026-01-02 556/week @ 2026-01-09 349/week @ 2026-01-16 527/week @ 2026-01-23 1158/week @ 2026-01-30 386/week @ 2026-02-06 319/week @ 2026-02-13 182/week @ 2026-02-20 277/week @ 2026-02-27

1,441 downloads per month
Used in 8 crates (6 directly)

Apache-2.0

64KB
1K SLoC

protosocket

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

Key Features

  • Low abstraction - no http or higher level constructs
  • Asynchronous I/O using mio via tokio
  • Flexible custom message types
  • Efficient, flexible buffer management

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 Decoder
    participant R as Reactor
    participant S as Encoder
    participant OS as Outbound Socket

    P->>IS: Read from inbound socket
    IS->>D: Connection read buffer
    D->>P: Deserialize inbound messages
    P->>R: Submit inbound messages
    R-->>P: Create response messages (asynchronous)
    P->>S: Prepare and serialize outbound messages
    S->>P: Serialized outbound buffer (bytes or other serialized view of a message)
    P->>OS: Write to outbound socket

Dependencies

~11–24MB
~357K SLoC