Skip to main content

awpak_rs/io/headers/
header_data.rs

1
2/// Represents an individual HTTP header.
3///
4/// This struct contains the name of the header and its value, which can be stored as a string or raw binary data.
5///
6/// # Fields
7///
8/// - `name` – The name of the header (e.g., `"Content-Type"`).
9/// - `value` *(optional)* – The header value as a `String` if it contains text data.
10/// - `value_bytes` – The header value in raw binary form.
11///
12/// # Notes
13///
14/// - If the header contains non-textual data, `value` will be `None`, and the raw data should be accessed via `value_bytes`.
15/// - If the header contains textual data, `value` will hold the string representation.
16#[derive(Clone)]
17pub struct HeaderData
18{
19    pub name : String,
20    pub value : Option<String>,
21    pub value_bytes : Vec<u8>
22}
23
24impl HeaderData
25{
26    pub fn new( name : String, value_bytes : Vec<u8>, value : Option<String> ) -> Self
27    {
28        Self
29        {
30            name,
31            value,
32            value_bytes
33        }
34    }
35}