Skip to main content

RelayClient

Struct RelayClient 

Source
pub struct RelayClient { /* private fields */ }

Implementations§

Source§

impl RelayClient

Source

pub fn new(base_url: &str) -> Self

Source

pub fn allocate_slot( &self, handle_hint: Option<&str>, ) -> Result<AllocateResponse>

Allocate a fresh slot. Returns (slot_id, slot_token) — caller MUST persist slot_token somewhere safe (mode 0600 file); it grants both read and write access to the slot.

Source

pub fn post_event( &self, slot_id: &str, slot_token: &str, event: &Value, ) -> Result<PostEventResponse>

POST a signed event to a slot. Caller passes the slot’s bearer token (the relay model in v0.1 is “shared slot token between paired peers” — see iter 9 SPAKE2 for how this token gets exchanged).

Source

pub fn list_events( &self, slot_id: &str, slot_token: &str, since: Option<&str>, limit: Option<usize>, ) -> Result<Vec<Value>>

GET events from a slot. since is an event_id cursor (exclusive); pass None for the full slot snapshot. limit defaults to 100, max 1000.

Source

pub fn slot_state( &self, slot_id: &str, slot_token: &str, ) -> Result<(usize, Option<u64>)>

R4 — probe slot attentiveness. Returns (event_count, last_pull_at_unix) — the relay’s view of the slot’s owner’s most recent poll. None for last_pull_at_unix means the slot has not been pulled since relay restart. Best-effort: any HTTP failure returns Ok((0, None)) so the caller’s pre-flight check degrades to “no signal” rather than abort.

Source

pub fn responder_health_set( &self, slot_id: &str, slot_token: &str, record: &Value, ) -> Result<Value>

Source

pub fn responder_health_get( &self, slot_id: &str, slot_token: &str, ) -> Result<Value>

Source

pub fn healthz(&self) -> Result<bool>

Source

pub fn check_healthz(&self) -> Result<()>

Healthz pre-flight that surfaces the underlying reqwest error in its own message. Use at every “is the relay reachable before we mutate state” site. The three possible failure modes (network error, 5xx from a reachable host, healthy) each get a distinct diagnostic line.

Source

pub fn pair_open( &self, code_hash: &str, msg_b64: &str, role: &str, ) -> Result<String>

Open or join a pair-slot. Returns the relay-assigned pair_id. role must be "host" or "guest". The host calls first; the guest uses the same code_hash and finds the existing slot.

Source

pub fn pair_abandon(&self, code_hash: &str) -> Result<()>

Forget the pair-slot at this code_hash on the relay. Either side can call; knowledge of the code is the only auth. Idempotent — succeeds even if the slot doesn’t exist. Use after a client crash mid-handshake so the host doesn’t stay locked out until TTL.

Source

pub fn pair_get( &self, pair_id: &str, as_role: &str, ) -> Result<(Option<String>, Option<String>)>

Read peer’s SPAKE2 message + (eventually) sealed bootstrap from a pair-slot.

Source

pub fn pair_bootstrap( &self, pair_id: &str, role: &str, sealed_b64: &str, ) -> Result<()>

POST a sealed bootstrap payload to the pair-slot.

Source

pub fn handle_claim( &self, nick: &str, slot_id: &str, slot_token: &str, relay_url: Option<&str>, card: &Value, ) -> Result<Value>

Claim a nick@<this-relay-domain> handle (v0.5). Caller must hold the bearer token for slot_id. FCFS on nick; same-DID re-claims OK.

Source

pub fn handle_intro(&self, nick: &str, event: &Value) -> Result<Value>

POST an intro (zero-paste pair-drop) event to a known nick’s slot without holding that slot’s bearer token. Relay validates the event is kind=1100 with an embedded signed agent-card; otherwise refuses.

Source

pub fn well_known_agent_card_a2a(&self, handle: &str) -> Result<Value>

Resolve a handle on this relay via A2A v1.0 .well-known/agent-card.json?handle=<nick>. Returns the parsed AgentCard JSON. Wire-served relays embed wire-native fields (DID, slot_id, profile, raw card) under extensions[0].params. Foreign A2A agents return their A2A card without wire ext — useful for wire whois even when full mailbox pairing isn’t possible.

Source

pub fn well_known_agent(&self, handle: &str) -> Result<Value>

Resolve a handle on this relay via .well-known/wire/agent?handle=<nick>. Caller passes either the full nick@domain or just <nick> — the server only uses the local part.

Trait Implementations§

Source§

impl Clone for RelayClient

Source§

fn clone(&self) -> RelayClient

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,