use crate::{AhpNotification, AhpRequest, AhpResponse, AuthConfig, Result};
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
pub enum Transport {
Stdio { program: String, args: Vec<String> },
#[cfg(feature = "http")]
Http {
url: String,
auth: Option<AuthConfig>,
},
#[cfg(feature = "websocket")]
WebSocket {
url: String,
auth: Option<AuthConfig>,
},
#[cfg(feature = "grpc")]
Grpc {
endpoint: String,
auth: Option<AuthConfig>,
},
#[cfg(feature = "unix-socket")]
UnixSocket { path: String },
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TransportConfig {
pub timeout_ms: u64,
pub max_retries: u32,
pub retry_delay_ms: u64,
}
impl Default for TransportConfig {
fn default() -> Self {
Self {
timeout_ms: 10_000,
max_retries: 3,
retry_delay_ms: 1_000,
}
}
}
#[async_trait]
pub trait TransportLayer: Send + Sync {
async fn send_request(&self, request: AhpRequest) -> Result<AhpResponse>;
async fn send_notification(&self, notification: AhpNotification) -> Result<()>;
async fn close(&self) -> Result<()>;
}
#[cfg(feature = "stdio")]
pub mod stdio;
#[cfg(feature = "http")]
pub mod http;
#[cfg(feature = "websocket")]
pub mod websocket;
#[cfg(feature = "grpc")]
pub mod grpc;
#[cfg(feature = "unix-socket")]
pub mod unix_socket;