WsClient::new
Construct a WsClient from a ws:// or wss:// URL.
Signature
pub fn new(url: impl Into<String>) -> Result<Self, anyhow::Error>;Example
use {anyhow::Result, dango_sdk::WsClient};
fn main() -> Result<()> {
let client = WsClient::new("wss://api-mainnet.dango.zone/graphql")?;
let _ = client;
Ok(())
}Parameters
url — impl Into<String>. A WebSocket URL. Must begin with ws:// or wss://.
Returns
WsClient — a cheap config holder. No network call is performed.
Notes
- Returns
Err(anyhow!("Invalid URL scheme: …"))for any non-WebSocket scheme. - Returns a
url::ParseError(wrapped) when the URL is malformed.
See also
from_http_url— accepthttp:///https://and rewrite the scheme.connect— open a connection.