http_type/response/
type.rs

1use super::error::Error as ResponseError;
2use lombok_macros::*;
3use std::collections::HashMap;
4
5///  Response data
6pub type ResponseData = Vec<u8>;
7
8///  Response body
9pub type ResponseBody = Vec<u8>;
10
11/// Response version
12pub type ResponseVersion = String;
13
14/// Response status code
15pub type ResponseStatusCode = usize;
16
17/// Response reason phrase
18pub type ResponseReasonPhrase = String;
19
20///  Response result
21pub type ResponseResult = Result<(), ResponseError>;
22
23///  Close stream result
24pub type CloseStreamResult = Result<(), ResponseError>;
25
26/// Represents an HTTP response.
27///
28/// # Fields
29/// - `version`: The HTTP version of the response (e.g., HTTP/1.1).
30/// - `status_code`: The status code of the response (e.g., 200, 404).
31/// - `reason_phrase`: The reason phrase corresponding to the status code (e.g., OK, Not Found).
32/// - `headers`: A collection of HTTP headers as key-value pairs.
33/// - `body`: The binary body of the response.
34/// - `response`: The serialized HTTP response including headers and body.
35#[derive(Debug, Clone, Lombok, PartialEq, Eq)]
36pub struct Response {
37    #[set(skip)]
38    pub(super) version: ResponseVersion,
39    pub(super) status_code: ResponseStatusCode,
40    #[set(skip)]
41    pub(super) reason_phrase: ResponseReasonPhrase,
42    pub(super) headers: HashMap<String, String>,
43    #[set(skip)]
44    pub(super) body: ResponseBody,
45    #[set(super)]
46    pub(super) response: ResponseData,
47}