rsrs_core/frame/
request_stream.rs

1use recode::bytes::BytesMut;
2use recode::codec::*;
3
4use super::validators::non_zero;
5use crate::{frame, FrameFlags};
6
7frame! {
8    /// REQUEST_STREAM Frame (0x06)
9    ///
10    /// # Frame Contents
11    ///
12    /// ```text
13    ///  0                   1                   2                   3
14    ///  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
15    /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16    /// |                           Stream ID                           |
17    /// +-----------+-+-+-+-------------+-------------------------------+
18    /// |Frame Type |0|M|F|    Flags    |
19    /// +-------------------------------+-------------------------------+
20    /// |0|                    Initial Request N                        |
21    /// +---------------------------------------------------------------+
22    ///                       Metadata & Request Data
23    /// ```
24    RequestStream [header] {
25        #mask = [METADATA | FOLLOW];
26
27        /// Initial Request N
28        ///
29        /// Unsigned 31-bit integer representing the initial number of items
30        /// to request. Value **MUST** be > 0.
31        @validate(r#"|v, b| non_zero("RequestStream.initial_request_n", v, b)"#);
32        pub initial_request_n(required): u32;
33
34        /// Request Metadata
35        ///
36        /// Identification of the service being requested along
37        /// with parameters for the request.
38        @skip_if("!header.has(FrameFlags::METADATA)");
39        @with("LengthPrefixed::<u24>");
40        pub metadata: BytesMut => [ set (METADATA if !metadata.is_empty()) ];
41
42        /// Request Data
43        ///
44        /// Identification of the service being requested along
45        /// with parameters for the request.
46        @with("Unprefixed");
47        pub data: BytesMut;
48    }
49}