Browse Source

Use doc comments in codec.rs some more.

wip
Titouan Rigoudy 6 years ago
parent
commit
0e2e684b26
1 changed files with 13 additions and 6 deletions
  1. +13
    -6
      src/proto/codec.rs

+ 13
- 6
src/proto/codec.rs View File

@ -1,3 +1,14 @@
//! This module provides tokio Codec implementations for protocol messages.
//!
//! Specifically, the following types:
//!
//! * proto::peer::Message
//! * proto::server::ServerRequest
//! * proto::server::ServerResponse
//!
//! This enables wrapping AsyncRead and AsyncWrite objects into Stream and Sink
//! objects using tokio_codec's FramedRead and FramedWrite adapters.
use std::io;
use std::marker;
@ -8,11 +19,7 @@ use super::base_codec::{ProtoDecode, ProtoDecoder, ProtoEncode, ProtoEncoder, U3
use super::peer::Message;
use super::server::{ServerRequest, ServerResponse};
/*===================================*
* TOKIO CODEC TRAIT IMPLEMENTATIONS *
*===================================*/
// Encodes types that implement ProtoEncode with a length prefix.
/// Implements tokio's Encoder trait for types that implement ProtoEncode.
pub struct LengthPrefixedEncoder<T> {
phantom: marker::PhantomData<T>,
}
@ -46,7 +53,7 @@ impl<T: ProtoEncode> tokio_codec::Encoder for LengthPrefixedEncoder<T> {
}
}
// Decodes length-prefixed values from byte buffers.
/// Implements tokio's Decoder trait for types that implement ProtoDecode.
pub struct LengthPrefixedDecoder<T> {
// The length, as a number of bytes, of the next item to decode.
// None if we have not read the length prefix yet.


Loading…
Cancel
Save