s2n_quic_core/frame/
path_response.rs1use crate::frame::Tag;
5use s2n_codec::{decoder_parameterized_value, Encoder, EncoderValue};
6
7macro_rules! path_response_tag {
12 () => {
13 0x1bu8
14 };
15}
16use crate::frame::path_challenge::{PathChallenge, DATA_LEN};
17
18#[derive(Debug, PartialEq, Eq)]
25pub struct PathResponse<'a> {
26 pub data: &'a [u8; DATA_LEN],
28}
29
30impl PathResponse<'_> {
31 pub const fn tag(&self) -> u8 {
32 path_response_tag!()
33 }
34}
35
36impl<'a> From<PathChallenge<'a>> for PathResponse<'a> {
37 fn from(path_challenge: PathChallenge<'a>) -> Self {
38 Self {
39 data: path_challenge.data,
40 }
41 }
42}
43
44decoder_parameterized_value!(
45 impl<'a> PathResponse<'a> {
46 fn decode(_tag: Tag, buffer: Buffer) -> Result<Self> {
47 let (path_challenge, buffer) =
48 buffer.decode_parameterized::<PathChallenge>(path_challenge_tag!())?;
49 Ok((path_challenge.into(), buffer))
50 }
51 }
52);
53
54impl EncoderValue for PathResponse<'_> {
55 fn encode<E: Encoder>(&self, buffer: &mut E) {
56 buffer.encode(&self.tag());
57 buffer.encode(&self.data.as_ref());
58 }
59}