Module volo_thrift::codec::default
source · Expand description
The default codec implementation. This mod contains the default implementation of codec.
We use some internal traits such as [ZeroCopyEncoder
] and [ZeroCopyDecoder
] to
make the implementation more flexible, which is not desired to be used by others, so
we don’t provide backward compatibility for them.
The main entrypoint is DefaultMakeCodec
which receives [MakeZeroCopyCodec
], and
then creates [DefaultEncoder
] and [DefaultDecoder
].
DefaultMakeCodec
implements MakeCodec
which is used by [Server
] and [Client
].
We make this mod public for those who want to implement their own codec and want to reuse some of the components.
The default codec contains some private protocols, such as TTHeader
, which can
only be used between Volo
and Kitex
services (currently). If you want to
use the standard thrift transport protocol, you can disable TTHeader
and use
Framed
instead.
Currently, the default codec protocol is TTHeader<Framed<Binary>>
.
Note: The default implementation of codec assumes that the transport and protocol won’t change across a connection.
Modules§
- TTheader is a transport protocol designed by CloudWeGo.
Structs§
MkZC
is a shorthand forMakeZeroCopyCodec
.
Traits§
ZeroCopyDecoder
tries to decode a message without copying large data, so theBytes
in the [decode
] method is not designed to be reused, and the implementation can useBytes::split_to
to get aBytes
and hand it to the user directly.ZeroCopyEncoder
tries to encode a message without copying large data taking the advantage ofLinkedBytes
, which can insert aBytes
into the middle of a [BytesMut
] and uses writev.