pub struct AgentId(/* private fields */);Expand description
Unique identifier for a runtime agent (format: agent_<uuid>)
Implementations§
Source§impl AgentId
impl AgentId
Sourcepub fn parse(s: impl AsRef<str>) -> Result<Self, IdError>
pub fn parse(s: impl AsRef<str>) -> Result<Self, IdError>
Parse an ID from a string, validating format
§Security
Failed parse attempts are logged when the telemetry feature is enabled.
This provides security monitoring for potential attack attempts.
Sourcepub fn parse_flexible(s: impl AsRef<str>) -> Result<Self, IdError>
pub fn parse_flexible(s: impl AsRef<str>) -> Result<Self, IdError>
Parse an ID accepting both current (underscore) and legacy (hyphen) formats
This method provides backward compatibility during migration periods when both ID formats may exist in the system (e.g., database, logs, external APIs).
§Format Support
- Current format (underscore):
prefix_uuid(e.g.,agent_abc123) - Legacy format (hyphen):
prefix-uuid(e.g.,agent-abc123)
The legacy format is automatically normalized to the current underscore format.
§Security
Failed parse attempts are logged when the telemetry feature is enabled,
regardless of which format was attempted.
§Production Migration
Use this method when:
- Reading IDs from databases that contain legacy format
- Deserializing IDs from old API responses or config files
- Processing IDs from external systems during migration
Once migration is complete, prefer parse() for strict validation.
§Example
use iron_types::AgentId;
// Current format
let id1 = AgentId::parse_flexible("agent_550e8400-e29b-41d4-a716-446655440000").unwrap();
// Legacy format (auto-normalized)
let id2 = AgentId::parse_flexible("agent-550e8400-e29b-41d4-a716-446655440000").unwrap();
// Both produce same normalized ID
assert_eq!(id1.as_str(), "agent_550e8400-e29b-41d4-a716-446655440000");
assert_eq!(id2.as_str(), "agent_550e8400-e29b-41d4-a716-446655440000");Trait Implementations§
Source§impl<'de> Deserialize<'de> for AgentId
impl<'de> Deserialize<'de> for AgentId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for AgentId
impl StructuralPartialEq for AgentId
Auto Trait Implementations§
impl Freeze for AgentId
impl RefUnwindSafe for AgentId
impl Send for AgentId
impl Sync for AgentId
impl Unpin for AgentId
impl UnwindSafe for AgentId
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)