Skip to main content

ServerClient

Struct ServerClient 

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

A live connection to the server. Cloneable handle; cloning shares the same underlying socket.

Implementations§

Source§

impl ServerClient

Source

pub async fn connect( url: &str, dial: &DialMode, identity: Arc<Identity>, rooms: Vec<String>, ) -> Result<(Self, UnboundedReceiver<ServerEvent>)>

Open a connection, send the initial hello, and return the client plus a stream of ServerEvents.

  • url: ws://<onion>:80/ws (onion), wss://relay/ws (clearnet TLS), or ws://host:port/ws (clearnet plain / tests).
  • dial: how to physically reach it — one of the transport “doors” (Socks5 for onion via Tor, Tls for wss://, Direct for ws://).
  • identity: our identity, used to answer the relay’s auth Challenge (huddle 1.1.4). The connector signs the challenge nonce and sends the pubkey + signature in Hello; the relay rejects us otherwise.
Source

pub fn publish(&self, room: &str, id: &str, payload: &[u8]) -> Result<()>

Send a room’s opaque wire bytes to the server for fan-out.

Source

pub fn send_direct( &self, to: &str, room: &str, id: &str, payload: &[u8], ) -> Result<()>

huddle 1.2: deliver payload straight to recipient to’s fingerprint, independent of room membership (1:1 DMs, friend requests). The server delivers it live to every connection to has open, or queues it in their mailbox when they’re offline. room is the opaque tag the recipient files it under.

Source

pub fn subscribe(&self, room: &str) -> Result<()>

Assert membership of a room so the server mailboxes us when offline.

Source

pub fn unsubscribe(&self, room: &str) -> Result<()>

Source

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

huddle 1.2.1: ask the relay to mint a short-lived connect code bound to our identity. The reply arrives as ServerEvent::ConnectToken.

Source

pub fn redeem_connect_token(&self, token: &str) -> Result<()>

huddle 1.2.1: ask the relay to resolve a connect code to its owner. The reply arrives as ServerEvent::ConnectTokenResolved.

Source

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

Ask the server to re-drain our mailbox.

Source

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

Trait Implementations§

Source§

impl Clone for ServerClient

Source§

fn clone(&self) -> ServerClient

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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