konduto/types/device/manufacturer.rs
1use crate::impl_nutype_error_conversion;
2use nutype::nutype;
3
4/// Fabricante do dispositivo (mínimo 2, máximo 225 caracteres)
5///
6/// # Validações
7/// - Não pode ser vazio (após trim)
8/// - Mínimo 2 caracteres
9/// - Máximo 225 caracteres
10///
11/// # Exemplos
12/// ```
13/// use konduto::manufacturer::DeviceManufacturer;
14///
15/// let manufacturer = DeviceManufacturer::try_new("Samsung").unwrap();
16/// assert_eq!(manufacturer.as_str(), "Samsung");
17/// ```
18#[nutype(
19 sanitize(trim),
20 validate(not_empty, len_char_min = 2, len_char_max = 225),
21 derive(
22 Debug,
23 Clone,
24 PartialEq,
25 Eq,
26 Display,
27 AsRef,
28 Deref,
29 Serialize,
30 Deserialize,
31 )
32)]
33pub struct DeviceManufacturer(String);
34
35impl DeviceManufacturer {
36 /// Retorna o fabricante como string slice (compatibilidade)
37 pub fn as_str(&self) -> &str {
38 self.as_ref()
39 }
40}
41
42impl_nutype_error_conversion!(DeviceManufacturerError);