pub struct Presence {
pub mode: Option<String>,
pub relay: Option<String>,
pub relays: Vec<String>,
pub rendezvous: Option<String>,
pub max_occupants: Option<u32>,
pub voice: bool,
pub owner_required: bool,
pub extra: Extra,
}Expand description
Presence policy — the (optional) upgrade from a solo world to a shared one.
Presence on the Thread is federated: a world names its own relay(s), so
there is no global chokepoint. Prefer relays — an ordered
list of interchangeable, conformant relays (primary first, then fallbacks) — so
no single relay URL is a point of failure. The singular relay
is retained for backward compatibility; relay_list
returns the effective, de-duplicated order to try.
Fields§
§mode: Option<String>Presence tier: "solo", "p2p", or "relay" (see presence-topology-v0.1).
Absent → inferred from whether any relay is named. Forward-looking; a browser
that only implements the relay tier treats "p2p" as a hint it may ignore.
Declaration, not fact. The address fields decide what a browser can
actually do; mode states what the author meant, and MUST agree. When
they disagree the addresses win — see Presence::effective_mode.
relay: Option<String>A single presence relay (legacy / old-browser compatibility). Absent → solo.
relays: Vec<String>Interchangeable relays to try in order (primary first, then fallbacks). Any conformant relay works; if one is unreachable the browser tries the next.
rendezvous: Option<String>Tier-1 P2P rendezvous URL (wss://…/rtc/<key>), meaningful with
mode: "p2p". A different protocol from a relay (mesh Signal
introduction, never poses), so it is a distinct field — relays keeps its
ordered-failover meaning unconditionally and MAY be present alongside as the
Tier-2 fallback when the mesh can’t form (the hybrid story).
max_occupants: Option<u32>Omitted when unset — null here reads as “someone thought about the
cap and chose nothing”, which is not what it means.
voice: boolAlways emitted: false is a decision about this room, not a gap.
owner_required: boolThe room lives only while its owner is present (a traveler’s home with guests over). When such a room closes, browsers SHOULD walk guests back to their own home rather than leave them in a dead copy of the world.
extra: ExtraUnknown fields, preserved across a round trip (see Extra).
Implementations§
Source§impl Presence
impl Presence
Sourcepub fn effective_mode(&self) -> &'static str
pub fn effective_mode(&self) -> &'static str
What this world can actually do, as opposed to what it says.
mode is a declaration; the address fields are the facts, and a
declaration that contradicts them is not a second source of truth. A
world claiming mode: "relay" with no relay named cannot host anyone,
and one naming a relay is not solo however it is labelled. An empty
relays: [] is the absence of a relay, never a considered choice of
none — a consumer deciding whether to supply one should read this rather
than test for a key, because which keys are present is an emitter’s
business and this is not.
Sourcepub fn mode_disagrees(&self) -> bool
pub fn mode_disagrees(&self) -> bool
Whether mode claims something the addresses don’t support — advisory,
for linters and conformance rather than for the render path.
Sourcepub fn relay_list(&self) -> Vec<String>
pub fn relay_list(&self) -> Vec<String>
The effective, ordered, de-duplicated list of relays to try: relays first,
then the legacy singular relay if it isn’t already present. Empty → solo.