simbld_http/helpers/
two_fields_tuple_helper.rs

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