unb-client 2.0.0

unb outbound client: WebSocket + in-process dialing (native) over the sans-IO core; wasm-safe
Documentation
use std::sync::Arc;

use unb_runtime::{ClientSession, Pipe, WsError};

use crate::{dial_endpoints, Endpoint, EndpointSet, TransportKind};

pub async fn dial(url: &str) -> Result<Arc<ClientSession>, WsError> {
    dial_endpoints(&EndpointSet::from(Endpoint {
        kind: TransportKind::WebSocket,
        address: url.to_owned(),
        cert_hash: None,
    }))
    .await
}

pub async fn dial_transport(url: &str) -> Result<Pipe, WsError> {
    let (pipe, initiator) = unb_transport::ws::dial(url).await?;
    Ok(Pipe::Piped { pipe, initiator })
}