Skip to main content

Presence

Struct Presence 

Source
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: bool

Always emitted: false is a decision about this room, not a gap.

§owner_required: bool

The 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: Extra

Unknown fields, preserved across a round trip (see Extra).

Implementations§

Source§

impl Presence

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Presence

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 Presence

Source§

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

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

impl Default for Presence

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Presence

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 Serialize for Presence

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> 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.