use async_trait::async_trait;
use thiserror::Error;
use kuri_mcp_protocol::jsonrpc::{JsonRpcResponse, SendableMessage};
#[async_trait]
pub trait Transport {
async fn send(
&self,
message: SendableMessage,
) -> Result<Option<JsonRpcResponse>, TransportError>;
}
#[derive(Error, Debug)]
pub enum TransportError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON serialisation error: {0}")]
Serialisation(#[from] serde_json::Error),
#[error("Invalid UTF-8 sequence: {0}")]
Utf8(#[from] std::string::FromUtf8Error),
#[error("Invalid message format: {0}")]
InvalidMessage(String),
#[error("Channel closed")]
ChannelClosed,
#[error("Stdio process error: {0}")]
StdioProcessError(String),
#[error("Transport unavailable (either closed or not started)")]
Unavailable,
}
mod byte_transport;
pub use byte_transport::ByteTransport;