I'm trying to get tokio-serde to work in a program I'm writing, and along the way I've found that I don't understand why the example code compiles. According to the documentation, tokio-serde's Framed
can only serve as a Sink
or Stream
if Codec::Error
can be converted Into
Transport::Error
. In the case of, say, the server.rs
example:
- The
Transport
is aFramedRead
, whoseError
is theError
of itsDecoder
, withDecoder
here beingLengthDelimitedCodec
, which hasLengthDelimitedCodecError
as itsError
, soTransport::Error
isLengthDelimitedCodecError
- The
Codec
istokio_serde::formats::Json
, whoseError
isjson_serde::Error
.
Now, I see that serde_json::Error
implements conversion to std::io::Error
, but how do we get from that to a LengthDelimitedCodecError
? I must be missing something in the documentation for one of these types, but I (obviously) don't see what.