pub struct TrustRoot { /* private fields */ }Expand description
A validated trust root (authority) from an agent URI.
The trust root identifies the authority that vouches for an agent’s identity and capabilities. It consists of a host (domain or IP) and an optional port.
§Examples
use agent_uri::TrustRoot;
let root = TrustRoot::parse("anthropic.com").unwrap();
assert_eq!(root.host_str(), "anthropic.com");
assert!(root.port().is_none());
let root = TrustRoot::parse("localhost:8472").unwrap();
assert_eq!(root.host_str(), "localhost");
assert_eq!(root.port(), Some(8472));Implementations§
Source§impl TrustRoot
impl TrustRoot
Sourcepub fn parse(input: &str) -> Result<Self, TrustRootError>
pub fn parse(input: &str) -> Result<Self, TrustRootError>
Parses a trust root from a string.
§Errors
Returns TrustRootError if:
- The input is empty
- The input exceeds 128 characters
- The domain contains invalid characters or labels
- The IP address is malformed
- The port is invalid (not numeric or out of range)
Sourcepub fn is_localhost(&self) -> bool
pub fn is_localhost(&self) -> bool
Returns true if this is a localhost address.
Sourcepub fn with_port(&self, port: u16) -> Result<Self, TrustRootError>
pub fn with_port(&self, port: u16) -> Result<Self, TrustRootError>
Returns a new trust root with the given port.
§Errors
Returns TrustRootError if the resulting trust root would exceed
the maximum length.
§Examples
use agent_uri::TrustRoot;
let root = TrustRoot::parse("localhost").unwrap();
let with_port = root.with_port(8472).unwrap();
assert_eq!(with_port.port(), Some(8472));Sourcepub fn without_port(&self) -> Self
pub fn without_port(&self) -> Self
Returns a new trust root without a port.
§Examples
use agent_uri::TrustRoot;
let root = TrustRoot::parse("localhost:8472").unwrap();
let without_port = root.without_port();
assert!(without_port.port().is_none());Trait Implementations§
impl Eq for TrustRoot
Source§impl Ord for TrustRoot
impl Ord for TrustRoot
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 TrustRoot
impl PartialOrd for TrustRoot
impl StructuralPartialEq for TrustRoot
Auto Trait Implementations§
impl Freeze for TrustRoot
impl RefUnwindSafe for TrustRoot
impl Send for TrustRoot
impl Sync for TrustRoot
impl Unpin for TrustRoot
impl UnsafeUnpin for TrustRoot
impl UnwindSafe for TrustRoot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PrefixFactory for T
impl<T> PrefixFactory for T
Source§fn create_prefix_sanitized(&self) -> TypeIdPrefix
fn create_prefix_sanitized(&self) -> TypeIdPrefix
Sanitizes the input and creates a valid
TypeIdPrefix. Read moreSource§fn try_create_prefix(&self) -> Result<TypeIdPrefix, ValidationError>
fn try_create_prefix(&self) -> Result<TypeIdPrefix, ValidationError>
Attempts to create a
TypeIdPrefix from the input without modifying it. Read more