pub struct AgentId(/* private fields */);Expand description
Caller-provided identifier for a Solti agent.
The model validates its format. The caller owns assignment and uniqueness.
use solti_model::AgentId;
// From a UUID
let id = AgentId::new("550e8400-e29b-41d4-a716-446655440000").unwrap();
assert_eq!(id.as_str(), "550e8400-e29b-41d4-a716-446655440000");
// From a Kubernetes pod name
let id = AgentId::new("worker-pod-7b9f4").unwrap();
assert_eq!(format!("{id}"), "worker-pod-7b9f4");Implementations§
Source§impl AgentId
impl AgentId
Sourcepub fn new(s: impl AsRef<str>) -> ModelResult<Self>
pub fn new(s: impl AsRef<str>) -> ModelResult<Self>
Creates a validated identifier.
§Errors
Returns crate::ModelError::Invalid when the value violates this identifier’s format.
Sourcepub fn into_inner(self) -> Arc<str>
pub fn into_inner(self) -> Arc<str>
Returns the underlying Arc<str>.
Source§impl AgentId
impl AgentId
Sourcepub fn validate_format(&self) -> Result<(), ModelError>
pub fn validate_format(&self) -> Result<(), ModelError>
Validates the agent id.
§Errors
Returns ModelError::Invalid when the value is empty, too long, equal to "." or "..", or contains a byte outside [A-Za-z0-9._-].
§Example
use solti_model::AgentId;
assert!(AgentId::new("worker-pod-7b9f4").is_ok());
assert!(AgentId::new("worker/pod").is_err());Trait Implementations§
Source§impl<'de> Deserialize<'de> for AgentId
impl<'de> Deserialize<'de> for AgentId
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes and validates the identifier.
impl Eq for AgentId
Source§impl JsonSchema for AgentId
impl JsonSchema for AgentId
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for AgentId
impl Ord for AgentId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for AgentId
impl PartialOrd 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 UnsafeUnpin for AgentId
impl UnwindSafe for AgentId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more