pub async fn connect(
config: ClientConfig,
sink: Box<dyn Sink>,
) -> Result<(ClientHandle, EventStream)>Expand description
Connects to a server and returns its handle and event stream.
The configuration is validated before this returns; the connection itself runs in a spawned
task and is reported through the event stream, with Event::Connected as the first event of a
successful attempt.
The task owns the sink and every attempt, so it reconnects after a drop with the same identity
and sink and with the level, mute state and roles the previous session had. Each drop is
reported as Event::Disconnected together with the delay before the next attempt. The
connection ends when the sink fails, which the host has to repair, or when the handle or the
event stream is dropped.
§Errors
Returns an error for an invalid ClientConfig and for a server address this build cannot use
(including a TLS URL). An unreachable server is not an error: the connection reports it as
Event::Disconnected and keeps retrying.
§Panics
Panics when called outside a Tokio runtime, because the connection is spawned.