
This PR abstracts the communication layer for context servers, laying the groundwork for supporting multiple transport mechanisms and taking one step towards enabling remote servers. Key changes centre around creating a new `Transport` trait with methods for sending and receiving messages. I've implemented this trait for the existing stdio-based communication, which is now encapsulated in a `StdioTransport` struct. The `Client` struct has been refactored to use this new `Transport` trait instead of directly managing stdin and stdout. The next steps will involve implementing an SSE + HTTP transport and defining alternative context server settings for remote servers. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
16 lines
394 B
Rust
16 lines
394 B
Rust
mod stdio_transport;
|
|
|
|
use std::pin::Pin;
|
|
|
|
use anyhow::Result;
|
|
use async_trait::async_trait;
|
|
use futures::Stream;
|
|
|
|
pub use stdio_transport::*;
|
|
|
|
#[async_trait]
|
|
pub trait Transport: Send + Sync {
|
|
async fn send(&self, message: String) -> Result<()>;
|
|
fn receive(&self) -> Pin<Box<dyn Stream<Item = String> + Send>>;
|
|
fn receive_err(&self) -> Pin<Box<dyn Stream<Item = String> + Send>>;
|
|
}
|