1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use super::{chunk_header::*, chunk_type::*, *};
use anyhow::Result;
use bytes::{Bytes, BytesMut};
use std::fmt;
#[derive(Debug, Clone)]
pub(crate) struct ChunkCookieAck;
impl fmt::Display for ChunkCookieAck {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.header())
}
}
impl Chunk for ChunkCookieAck {
fn header(&self) -> ChunkHeader {
ChunkHeader {
typ: CT_COOKIE_ACK,
flags: 0,
value_length: self.value_length() as u16,
}
}
fn unmarshal(raw: &Bytes) -> Result<Self> {
let header = ChunkHeader::unmarshal(raw)?;
if header.typ != CT_COOKIE_ACK {
return Err(Error::ErrChunkTypeNotCookieAck.into());
}
Ok(ChunkCookieAck {})
}
fn marshal_to(&self, buf: &mut BytesMut) -> Result<usize> {
self.header().marshal_to(buf)?;
Ok(buf.len())
}
fn check(&self) -> Result<()> {
Ok(())
}
fn value_length(&self) -> usize {
0
}
fn as_any(&self) -> &(dyn Any + Send + Sync) {
self
}
}