fn len(&self) -> usize {
        // type length + value length
        // only keepalive has no type length or value length
        match self {
            Message::Keepalive => 0,
            Message::Choke => 1,
            Message::Unchoke => 1,
            Message::Interested => 1,
            Message::NotInterested => 1,
            Message::Have { .. } => 1 + 4,
            Message::Bitfield { bitfield } => 1 + bitfield.as_raw_slice().len(),
            Message::Request { .. } => 1 + 4 + 4 + 4,
            Message::Piece { chunk, .. } => 1 + 4 + 4 + chunk.len(),
            Message::Cancel { .. } => 1 + 4 + 4 + 4,
        }
    }
/// in the bittorrent protocol,
/// messages are of the form "LTV", or Length Type Value,
/// where Length is a 4 byte big endian u32,
/// Type is a single byte, and Value is a sequence of bytes
/// of length Length - 1 (for the type tag byte).
/// Keepalive alone has no Tag byte or Value, only a four-byte length of 0,
/// i.e., "0u8 0u8 0u8 0u8"
in the bittorrent protocol,
messages are of the form "LTV", or Length Type Value,
where Length is a 4 byte big endian u32,
Type is a single byte, and Value is a sequence of bytes
of length Length - 1 (for the type tag byte).
Keepalive alone has no Tag byte or Value, only a four-byte length of 0,
i.e., "0u8 0u8 0u8 0u8"
in the bittorrent protocol messages are of the form " LTV " or Length Type Value where Length is a 4 byte big endian u32 Type is a single byte and Value is a sequence of bytes of length Length - 1 ( for the type tag byte ) . Keepalive alone has no Tag byte or Value only a four - byte length of 0 i . e . " 0u8 0u8 0u8 0u8 "
fn len(&self) -> usize {
        // type length + value length
        // only keepalive has no type length or value length
        match self {
            Message::Keepalive => 0,
            Message::Choke => 1,
            Message::Unchoke => 1,
            Message::Interested => 1,
            Message::NotInterested => 1,
            Message::Have { .. } => 1 + 4,
            Message::Bitfield { bitfield } => 1 + bitfield.as_raw_slice().len(),
            Message::Request { .. } => 1 + 4 + 4 + 4,
            Message::Piece { chunk, .. } => 1 + 4 + 4 + chunk.len(),
            Message::Cancel { .. } => 1 + 4 + 4 + 4,
        }
    }
fn len ( & self ) -> usize { // type length + value length // only keepalive has no type length or value length match self { Message :: Keepalive => 0 , Message :: Choke => 1 , Message :: Unchoke => 1 , Message :: Interested => 1 , Message :: NotInterested => 1 , Message :: Have { .. } => 1 + 4 , Message :: Bitfield { bitfield } => 1 + bitfield . as_raw_slice ( ) . len ( ) , Message :: Request { .. } => 1 + 4 + 4 + 4 , Message :: Piece { chunk , .. } => 1 + 4 + 4 + chunk . len ( ) , Message :: Cancel { .. } => 1 + 4 + 4 + 4 , } }
in the bittorrent protocol,
messages are of the form "LTV", or Length Type Value,
where Length is a 4 byte big endian u32,
Type is a single byte, and Value is a sequence of bytes
of length Length - 1 (for the type tag byte).
in the bittorrent protocol messages are of the form " LTV " or Length Type Value where Length is a 4 byte big endian u32 Type is a single byte and Value is a sequence of bytes of length Length - 1 ( for the type tag byte ) .
&self
&self