s2n_quic_core/frame/
max_stream_data.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::varint::VarInt;
5
6//= https://www.rfc-editor.org/rfc/rfc9000#section-19.10
7//# A MAX_STREAM_DATA frame (type=0x11) is used in flow control to inform
8//# a peer of the maximum amount of data that can be sent on a stream.
9
10macro_rules! max_stream_data_tag {
11    () => {
12        0x11u8
13    };
14}
15
16//= https://www.rfc-editor.org/rfc/rfc9000#section-19.10
17//# MAX_STREAM_DATA Frame {
18//#   Type (i) = 0x11,
19//#   Stream ID (i),
20//#   Maximum Stream Data (i),
21//# }
22
23//= https://www.rfc-editor.org/rfc/rfc9000#section-19.10
24//# MAX_STREAM_DATA frames contain the following fields:
25//#
26//# Stream ID:  The stream ID of the affected stream, encoded as a
27//# variable-length integer.
28//#
29//# Maximum Stream Data:  A variable-length integer indicating the
30//# maximum amount of data that can be sent on the identified stream,
31//# in units of bytes.
32
33#[derive(Copy, Clone, Debug, PartialEq, Eq)]
34pub struct MaxStreamData {
35    /// The stream ID of the stream that is affected encoded as a
36    /// variable-length integer.
37    pub stream_id: VarInt,
38
39    /// A variable-length integer indicating the maximum amount of data
40    /// that can be sent on the identified stream, in units of bytes.
41    pub maximum_stream_data: VarInt,
42}
43
44impl MaxStreamData {
45    pub const fn tag(&self) -> u8 {
46        max_stream_data_tag!()
47    }
48}
49
50simple_frame_codec!(
51    MaxStreamData {
52        stream_id,
53        maximum_stream_data
54    },
55    max_stream_data_tag!()
56);