s2n_quic_core/frame/
stop_sending.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.5
7//# An endpoint uses a STOP_SENDING frame (type=0x05) to communicate that
8//# incoming data is being discarded on receipt per application request.
9//# STOP_SENDING requests that a peer cease transmission on a stream.
10
11macro_rules! stop_sending_tag {
12    () => {
13        0x05u8
14    };
15}
16
17//= https://www.rfc-editor.org/rfc/rfc9000#section-19.5
18//# STOP_SENDING Frame {
19//#   Type (i) = 0x05,
20//#   Stream ID (i),
21//#   Application Protocol Error Code (i),
22//# }
23
24//= https://www.rfc-editor.org/rfc/rfc9000#section-19.5
25//# STOP_SENDING frames contain the following fields:
26//#
27//# Stream ID:  A variable-length integer carrying the stream ID of the
28//# stream being ignored.
29//#
30//# Application Protocol Error Code:  A variable-length integer
31//# containing the application-specified reason the sender is ignoring
32//# the stream; see Section 20.2.
33
34#[derive(Copy, Clone, Debug, PartialEq, Eq)]
35pub struct StopSending {
36    /// A variable-length integer carrying the Stream ID of the
37    /// stream being ignored.
38    pub stream_id: VarInt,
39
40    /// A variable-length integer containing the application-specified
41    /// reason the sender is ignoring the stream
42    pub application_error_code: VarInt,
43}
44
45impl StopSending {
46    pub const fn tag(&self) -> u8 {
47        stop_sending_tag!()
48    }
49}
50
51simple_frame_codec!(
52    StopSending {
53        stream_id,
54        application_error_code
55    },
56    stop_sending_tag!()
57);