Skip to main content

http_type/attribute/
impl.rs

1use crate::*;
2
3/// Implementation of `From` trait for `Attribute`.
4impl From<&str> for Attribute {
5    /// Converts a string slice into an `Attribute`.
6    ///
7    /// # Arguments
8    ///
9    /// - `&str` - The string slice to convert.
10    ///
11    /// # Returns
12    ///
13    /// - `Attribute` - The converted attribute key.
14    #[inline(always)]
15    fn from(key: &str) -> Self {
16        Attribute::External(key.to_string())
17    }
18}
19
20/// Implementation of `From` trait for `Attribute`.
21impl From<String> for Attribute {
22    /// Converts a `String` into an `Attribute`.
23    ///
24    /// # Arguments
25    ///
26    /// - `String` - The string to convert.
27    ///
28    /// # Returns
29    ///
30    /// - `Attribute` - The converted attribute key.
31    #[inline(always)]
32    fn from(key: String) -> Self {
33        Attribute::External(key)
34    }
35}
36
37/// Implementation of `From` trait for `Attribute`.
38impl From<InternalAttribute> for Attribute {
39    /// Converts an `InternalAttribute` into an `Attribute`.
40    ///
41    /// # Arguments
42    ///
43    /// - `InternalAttribute` - The internal attribute key to convert.
44    ///
45    /// # Returns
46    ///
47    /// - `Attribute` - The converted attribute key.
48    #[inline(always)]
49    fn from(key: InternalAttribute) -> Self {
50        Attribute::Internal(key)
51    }
52}