httlib_hpack/encoder/
input.rs

1/// Provides encoder input format options.
2#[derive(Debug)]
3pub enum EncoderInput {
4    /// Represents a fully indexed header field.
5    Indexed(u32),
6
7    /// Represents a header field where name is represented by an index and the
8    /// value is provided in bytes. This format can hold configuration flags.
9    IndexedName(u32, Vec<u8>, u8),
10
11    /// Represents a header field where name and value are provided in bytes.
12    /// This format can hold configuration flags.
13    Literal(Vec<u8>, Vec<u8>, u8),
14}
15
16impl<'a> From<u32> for EncoderInput {
17    fn from(field: u32) -> Self {
18        EncoderInput::Indexed(field)
19    }
20}
21
22impl<'a> From<(u32, Vec<u8>, u8)> for EncoderInput {
23    fn from(field: (u32, Vec<u8>, u8)) -> Self {
24        EncoderInput::IndexedName(field.0, field.1, field.2)
25    }
26}
27
28impl<'a> From<(Vec<u8>, Vec<u8>, u8)> for EncoderInput {
29    fn from(field: (Vec<u8>, Vec<u8>, u8)) -> Self {
30        EncoderInput::Literal(field.0, field.1, field.2)
31    }
32}