pub struct WsTransport { /* private fields */ }Expand description
WebSocket transport for communicating with a Haystack server.
Uses a JSON envelope with Zinc-encoded grid bodies:
- Request:
{"id": "<counter>", "op": "<op_name>", "body": "<zinc_grid>"} - Response:
{"id": "<counter>", "body": "<zinc_grid>"}
Supports concurrent in-flight requests by matching response IDs to pending oneshot channels via a background reader task.
Implementations§
Source§impl WsTransport
impl WsTransport
Sourcepub async fn connect(url: &str, auth_token: &str) -> Result<Self, ClientError>
pub async fn connect(url: &str, auth_token: &str) -> Result<Self, ClientError>
Connect to a Haystack server via WebSocket.
url should be a ws:// or wss:// URL to the server’s WebSocket endpoint.
auth_token is the bearer token obtained from SCRAM authentication.
Sourcepub async fn connect_with_timeout(
url: &str,
auth_token: &str,
timeout: Duration,
) -> Result<Self, ClientError>
pub async fn connect_with_timeout( url: &str, auth_token: &str, timeout: Duration, ) -> Result<Self, ClientError>
Connect with a custom request timeout.
Trait Implementations§
Source§impl Drop for WsTransport
impl Drop for WsTransport
Auto Trait Implementations§
impl !Freeze for WsTransport
impl !RefUnwindSafe for WsTransport
impl Send for WsTransport
impl Sync for WsTransport
impl Unpin for WsTransport
impl UnsafeUnpin for WsTransport
impl !UnwindSafe for WsTransport
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