irtt_client/managed/
target_id.rs1use std::{fmt, sync::Arc};
2
3#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub struct TargetId(Arc<str>);
6
7impl TargetId {
8 pub fn new(value: impl Into<Arc<str>>) -> Self {
10 Self(value.into())
11 }
12
13 pub fn as_str(&self) -> &str {
15 &self.0
16 }
17}
18
19impl fmt::Debug for TargetId {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 f.debug_tuple("TargetId").field(&self.0).finish()
22 }
23}
24
25impl fmt::Display for TargetId {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 f.write_str(&self.0)
28 }
29}
30
31impl From<&str> for TargetId {
32 fn from(value: &str) -> Self {
33 Self::new(value)
34 }
35}
36
37impl From<String> for TargetId {
38 fn from(value: String) -> Self {
39 Self::new(value)
40 }
41}
42
43impl AsRef<str> for TargetId {
44 fn as_ref(&self) -> &str {
45 self.as_str()
46 }
47}