Expand description
This is async-proto
, a library crate facilitating simple binary network protocols with async
support.
The main feature is the Protocol
trait, which allows reading a value of an implementing type from an async or sync stream, as well as writing one to an async or sync sink.
Protocol
can be derived for enum
s and struct
s if all fields implement Protocol
.
§Features
This crate offers optional dependencies on the following crates to enable Protocol
implementations for some of their types:
bytes
:Bytes
chrono
:NaiveDate
,DateTime
,Utc
, andFixedOffset
chrono-tz
:Tz
doubloon
:Money
and all ISO currencieseither
:Either
enumset
:EnumSet
git2
:Oid
gix-hash
:ObjectId
noisy_float
:NoisyFloat
rust_decimal
:Decimal
semver
:Version
,Prerelease
, andBuildMetadata
serde_json
:Value
,Map
, andNumber
serenity
: The ID types, not includingShardId
uuid
:Uuid
Additionally, this crate offers optional dependencies on the tokio-tungstenite
crate to add convenience methods for reading/writing Protocol
types from/to its websockets. The following versions are supported:
- The latest release (currently
tokio-tungstenite
0.26, feature flagtokio-tungstenite026
) - The version used by the
master
branch ofrocket_ws
on GitHub (currentlytokio-tungstenite
0.24, feature flagtokio-tungstenite024
) - The version used by the latest
rocket_ws
crates.io release (currentlytokio-tungstenite
0.21, feature flagtokio-tungstenite021
)
Macros§
- bitflags
- Implements
Protocol
for a type defined using thebitflags::bitflags
macro.
Structs§
- Read
Error - The error returned from the
read
andread_sync
methods. - Write
Error - The error returned from the
write
andwrite_sync
methods.
Enums§
- Error
Context - Provides additional information about the origin of an error.
- Read
Error Kind - Specifies what went wrong while reading (receiving) a value.
- Write
Error Kind - Specifies what went wrong while writing (sending) a value.
Traits§
- Protocol
- This trait allows reading a value of an implementing type from an async or sync stream, as well as writing one to an async or sync sink.
Functions§
- websocket021
tokio-tungstenite021
- Establishes a WebSocket connection to the given URL and returns a typed sink/stream pair.
- websocket024
tokio-tungstenite024
- Establishes a WebSocket connection to the given URL and returns a typed sink/stream pair.
- websocket026
tokio-tungstenite026
- Establishes a WebSocket connection to the given URL and returns a typed sink/stream pair.
Derive Macros§
- Protocol
- Implements the
Protocol
trait for this type.