pub struct RelayClient { /* private fields */ }Implementations§
Source§impl RelayClient
impl RelayClient
pub fn new(base_url: &str) -> Self
Sourcepub fn allocate_slot(
&self,
handle_hint: Option<&str>,
) -> Result<AllocateResponse>
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.
Sourcepub fn post_event(
&self,
slot_id: &str,
slot_token: &str,
event: &Value,
) -> Result<PostEventResponse>
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).
Sourcepub fn list_events(
&self,
slot_id: &str,
slot_token: &str,
since: Option<&str>,
limit: Option<usize>,
) -> Result<Vec<Value>>
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.
Sourcepub fn slot_state(
&self,
slot_id: &str,
slot_token: &str,
) -> Result<(usize, Option<u64>)>
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.
pub fn responder_health_set( &self, slot_id: &str, slot_token: &str, record: &Value, ) -> Result<Value>
pub fn responder_health_get( &self, slot_id: &str, slot_token: &str, ) -> Result<Value>
pub fn healthz(&self) -> Result<bool>
Sourcepub fn check_healthz(&self) -> Result<()>
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.
Sourcepub fn pair_open(
&self,
code_hash: &str,
msg_b64: &str,
role: &str,
) -> Result<String>
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.
Sourcepub fn pair_abandon(&self, code_hash: &str) -> Result<()>
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.
Sourcepub fn pair_get(
&self,
pair_id: &str,
as_role: &str,
) -> Result<(Option<String>, Option<String>)>
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.
Sourcepub fn pair_bootstrap(
&self,
pair_id: &str,
role: &str,
sealed_b64: &str,
) -> Result<()>
pub fn pair_bootstrap( &self, pair_id: &str, role: &str, sealed_b64: &str, ) -> Result<()>
POST a sealed bootstrap payload to the pair-slot.
Sourcepub fn handle_claim(
&self,
nick: &str,
slot_id: &str,
slot_token: &str,
relay_url: Option<&str>,
card: &Value,
) -> Result<Value>
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.
Sourcepub fn handle_intro(&self, nick: &str, event: &Value) -> Result<Value>
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.
Sourcepub fn well_known_agent_card_a2a(&self, handle: &str) -> Result<Value>
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.
Sourcepub fn well_known_agent(&self, handle: &str) -> Result<Value>
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
impl Clone for RelayClient
Source§fn clone(&self) -> RelayClient
fn clone(&self) -> RelayClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more