simbld_http/helpers/
three_fields_tuple_helper.rs

1use crate::helpers::http_code_helper::HttpCode;
2use crate::traits::tuple_traits::IntoThreeFieldsTuple;
3use serde::Serialize;
4
5/// SimpleTuple represents a simplified view of HttpCode with three fields.
6#[derive(Debug, Serialize)]
7pub struct ThreeFieldsTuple {
8    pub code: u16,
9    pub name: &'static str,
10    pub description: &'static str,
11}
12
13impl ThreeFieldsTuple {
14    /// Create a new ThreeFieldsTuple from a HttpCode.
15    pub fn from_http_code(http_code: &HttpCode) -> Self {
16        Self {
17            code: http_code.standard_code,
18            name: http_code.standard_name,
19            description: http_code.unified_description,
20        }
21    }
22}
23
24impl IntoThreeFieldsTuple for HttpCode {
25    fn into_three_fields_tuple(self) -> ThreeFieldsTuple {
26        ThreeFieldsTuple::from_http_code(&self)
27    }
28}