haystack_client/transport/mod.rs
1pub mod http;
2pub mod ws;
3
4use crate::error::ClientError;
5use haystack_core::data::HGrid;
6
7/// Transport abstraction for communicating with a Haystack server.
8///
9/// Implementations send a request grid to a named op and return the response grid.
10/// Rust 2024 edition supports async fn in traits natively.
11pub trait Transport: Send + Sync {
12 /// Call a Haystack op with the given request grid and return the response grid.
13 fn call(
14 &self,
15 op: &str,
16 req: &HGrid,
17 ) -> impl std::future::Future<Output = Result<HGrid, ClientError>> + Send;
18
19 /// Close the transport, releasing any resources.
20 fn close(&self) -> impl std::future::Future<Output = Result<(), ClientError>> + Send;
21}