Expand description
This crate provides an interface to build a family of backend implementations using the
serde
crate to transport Serialize
and Deserialize
values by reference across
any AsyncRead
and AsyncWrite
transports. In order to use it, you will need to depend on
some other crate which provides the definition of a serialization format; none such are defined
here.
To use this backend, select:
- a particular serialization format, such as from the
dialectic_tokio_serde_bincode
ordialectic_tokio_serde_json
crates, - a particular
codec
for encoding and decoding frames, and - your choice of
AsyncRead
andAsyncWrite
reader and writer.
Then, use symmetrical
(_with_capacity
) to
construct a pair of Sender
and Receiver
.
If your outgoing and incoming streams are encoded or serialized differently, or your
serialization or encoding format is not Clone
, use Sender::new
and Receiver::new
directly to construct each end of the connection.
Re-exports§
pub use tokio_util::codec;
Structs§
- Receiver
- A
Receiver<F, D, R>
is capable of receiving anyDeserialize
value using the serialization formatF
and the frame decodingD
, from the asynchronous readerR
. - Sender
- A
Sender<F, E, W>
is capable of sending anySerialize
value using the serialization formatF
and the frame encodingE
to the asynchronous writerW
.
Enums§
- Error
- An error during operations on a
Sender
orReceiver
, unifyingSendError
andRecvError
. - Recv
Error - An error while receiving from a
Receiver
. - Send
Error - An error while sending on a
Sender
.
Traits§
- Deserializer
- The deserialization end of a serialization format: an object which can deserialize to any
non-lifetime-restricted
Deserialize
value. - Serializer
- The serialization end of a serialization format: an object which can serialize any
Serialize
value.
Functions§
- symmetrical
- Create a
Sender
/Receiver
pair which use the same serialization format and frame encoding in both directions. - symmetrical_
with_ capacity - Create a
Sender
/Receiver
pair which use the same serialization format and frame encoding in both directions, allocating an initial capacity for the read buffer on the receiver.
Type Aliases§
- Symmetrical
Chan - A
Chan
for the session typeS
and the environmentE
, using a symmetrical serialization/encoding and theAsyncWrite
/AsyncRead
pairW
/R
as transport. - Symmetrical
Error - Shorthand for an
Error
resulting from a symmetrically serialized/encoded connection.