Skip to main content

Registration

Struct Registration 

Source
pub struct Registration { /* private fields */ }
Expand description

A registration record stored in the DHT.

Contains all information needed to contact an agent and verify its identity. Registrations have a TTL and must be refreshed to remain active.

§Mutability

A record names the Ed25519 key that is allowed to change it. Every later write must carry a MutationProof signed by that key, and must advance Registration::sequence. Without both, knowing an agent’s URI would be enough to repoint it at attacker infrastructure.

§Examples

use std::time::Duration;
use agent_uri::AgentUri;
use agent_uri_attestation::SigningKey;
use agent_uri_dht::{Endpoint, Registration};

let uri = AgentUri::parse("agent://anthropic.com/assistant/chat/llm_01h455vb4pex5vsknk084sn02q").unwrap();
let endpoint = Endpoint::https("agent.anthropic.com:443");
let agent_key = SigningKey::generate();

let registration = Registration::new(uri, agent_key.verifying_key(), vec![endpoint])
    .with_ttl(Duration::from_secs(3600));

Implementations§

Source§

impl Registration

Source

pub const DEFAULT_TTL: Duration

Default TTL for registrations (1 hour).

Source

pub fn new( agent_uri: AgentUri, agent_key: VerifyingKey, endpoints: Vec<Endpoint>, ) -> Self

Creates a new registration with default TTL.

§Arguments
  • agent_uri - The agent’s identity URI
  • agent_key - The public key that may later change or remove this record
  • endpoints - Network endpoints for contacting the agent
Source

pub fn with_ttl(self, ttl: Duration) -> Self

Sets the TTL for this registration.

Source

pub fn with_attestation(self, attestation: impl Into<String>) -> Self

Sets the attestation token.

Source

pub fn with_expires_at(self, expires_at: SystemTime) -> Self

Sets the expiration time directly.

Source

pub fn with_registered_at(self, registered_at: SystemTime) -> Self

Sets the registration time (for testing/simulation).

Source

pub const fn with_sequence(self, sequence: u64) -> Self

Sets the sequence number this record starts its history at.

Records open at zero, which is right for an agent registering a URI for the first time. An agent that has held this URI before should instead continue past the highest sequence it ever signed: a record that starts over at zero sits below every proof its previous incarnation handed out, and a kept deregistration could evict it again each time it returns.

Source

pub fn agent_uri(&self) -> &AgentUri

Returns the agent URI.

Source

pub fn agent_key(&self) -> &VerifyingKey

Returns the key permitted to change or remove this record.

Source

pub const fn sequence(&self) -> u64

Returns the sequence number of the last write applied to this record.

A write must present a strictly greater number, so a caller preparing a mutation signs sequence() + 1.

Source

pub fn endpoints(&self) -> &[Endpoint]

Returns the endpoints.

Source

pub fn attestation(&self) -> Option<&str>

Returns the attestation token, if any.

Source

pub fn expires_at(&self) -> SystemTime

Returns the expiration time.

Source

pub fn registered_at(&self) -> SystemTime

Returns the registration time.

Source

pub fn is_expired(&self) -> bool

Returns true if this registration has expired.

Source

pub fn remaining_ttl(&self) -> Option<Duration>

Returns the remaining TTL, or None if expired.

Source

pub fn update_endpoints(&mut self, endpoints: Vec<Endpoint>)

Updates the endpoints for this registration.

Source

pub const fn set_expires_at(&mut self, expires_at: SystemTime)

Moves the registration’s expiry to an instant a write has authorized.

Callers are the store, applying a write it has already checked. The instant is taken rather than derived from a TTL because it is what the agent signed: a store that computed now + ttl for itself would write an expiry the agent never put its name to, and on a wire protocol that field would then be one an observer could rewrite freely.

registered_at is deliberately left alone. It identifies this record instance, which is what a MutationProof binds itself to; moving it on every refresh would invalidate proofs an agent had already prepared, and would make the field misreport when the agent actually registered.

Source

pub const fn set_sequence(&mut self, sequence: u64)

Records the sequence number of a write that has been authorized.

Callers are the store, applying a write it has already checked. The number is not validated here: whether it advances is a question about the record’s history, which only the store holding that record can answer.

Trait Implementations§

Source§

impl Clone for Registration

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Registration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Registration

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Registration

Source§

impl Hash for Registration

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Registration

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Registration

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V