rtm_core/models/
client_id.rs1use std::num::ParseIntError;
2
3#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
5#[repr(transparent)]
6#[must_use]
7pub struct ClientId {
8 value: u16,
9}
10
11impl ClientId {
12 #[must_use]
13 pub const fn as_u16(&self) -> u16 {
14 self.value
15 }
16}
17
18impl From<u16> for ClientId {
19 fn from(value: u16) -> Self {
20 Self { value }
21 }
22}
23
24impl TryFrom<&str> for ClientId {
25 type Error = ParseIntError;
26
27 fn try_from(value: &str) -> Result<Self, Self::Error> {
28 let value = value.parse::<u16>()?;
29 Ok(Self { value })
30 }
31}