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 enums and structs if all fields implement Protocol.
§Features
This crate offers optional dependencies on the following crates to enable Protocol implementations for some of their types:
bitvec:BitVec<u8, Lsb0>bytes:Bytesbytesize:ByteSizechrono:NaiveDate,DateTime,Utc, andFixedOffsetchrono-tz:Tzdoubloon:Moneyand all ISO currencieseither:Eitherenumset:EnumSetgit2:Oidgix-hash:ObjectIdnoisy_float:NoisyFloatnonempty-collections:NEMap,NESet, andNEVecrust_decimal:Decimalsemver:Version,Prerelease, andBuildMetadataserde_json:Value,Map, andNumberserenity: The ID types, not includingShardIdurl:Urluuid: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-tungstenite0.28, feature flagtokio-tungstenite028) - The version used by the
masterbranch ofrocket_wson GitHub (currentlytokio-tungstenite0.24, feature flagtokio-tungstenite024) - The version used by the latest
rocket_wscrates.io release (currentlytokio-tungstenite0.21, feature flagtokio-tungstenite021)
Macros§
- bitflags
- Implements
Protocolfor a type defined using thebitflags::bitflagsmacro.
Structs§
- Read
Error - The error returned from the
readandread_syncmethods. - Write
Error - The error returned from the
writeandwrite_syncmethods.
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§
- Length
Prefixed - This trait allows restricting the acceptable length of collection types.
- 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.
- websocket028
tokio-tungstenite028 - Establishes a WebSocket connection to the given URL and returns a typed sink/stream pair.
Derive Macros§
- Protocol
- Implements the
Protocoltrait for this type.