1#[cfg(feature = "typed-ids")]
7pub use stack_ids::EntityId as AgentId;
8
9#[cfg(not(feature = "typed-ids"))]
10#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
11#[serde(transparent)]
12pub struct AgentId(pub String);
13
14#[cfg(not(feature = "typed-ids"))]
15impl AgentId {
16 pub fn new(value: impl Into<String>) -> Self {
18 Self(value.into())
19 }
20
21 pub fn as_str(&self) -> &str {
23 &self.0
24 }
25
26 pub fn is_empty(&self) -> bool {
28 self.0.is_empty()
29 }
30}
31
32#[cfg(not(feature = "typed-ids"))]
33impl std::fmt::Display for AgentId {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 f.write_str(&self.0)
36 }
37}
38
39#[cfg(not(feature = "typed-ids"))]
40impl From<String> for AgentId {
41 fn from(value: String) -> Self {
42 Self(value)
43 }
44}
45
46#[cfg(not(feature = "typed-ids"))]
47impl From<&str> for AgentId {
48 fn from(value: &str) -> Self {
49 Self(value.to_string())
50 }
51}
52
53#[cfg(not(feature = "typed-ids"))]
54impl AsRef<str> for AgentId {
55 fn as_ref(&self) -> &str {
56 &self.0
57 }
58}