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
impl ServerClient
Sourcepub async fn connect(
url: &str,
dial: &DialMode,
fingerprint: String,
rooms: Vec<String>,
) -> Result<(Self, UnboundedReceiver<ServerEvent>)>
pub async fn connect( url: &str, dial: &DialMode, fingerprint: String, 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), orws://host:port/ws(clearnet plain / tests).dial: how to physically reach it — one of the transport “doors” (Socks5for onion via Tor,Tlsforwss://,Directforws://).
Sourcepub fn publish(&self, room: &str, id: &str, payload: &[u8]) -> Result<()>
pub fn publish(&self, room: &str, id: &str, payload: &[u8]) -> Result<()>
Send a room’s opaque wire bytes to the server for fan-out.
Sourcepub fn subscribe(&self, room: &str) -> Result<()>
pub fn subscribe(&self, room: &str) -> Result<()>
Assert membership of a room so the server mailboxes us when offline.
pub fn unsubscribe(&self, room: &str) -> Result<()>
pub fn ping(&self) -> Result<()>
Trait Implementations§
Source§impl Clone for ServerClient
impl Clone for ServerClient
Source§fn clone(&self) -> ServerClient
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ServerClient
impl RefUnwindSafe for ServerClient
impl Send for ServerClient
impl Sync for ServerClient
impl Unpin for ServerClient
impl UnsafeUnpin for ServerClient
impl UnwindSafe for ServerClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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