use std::path::PathBuf;
pub type AgentClientResult<T> = std::result::Result<T, AgentClientError>;
#[derive(Debug, thiserror::Error)]
pub enum AgentClientError {
#[error("connect {path}: {source}")]
Connect {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("handshake: {0}")]
Handshake(String),
#[error("sandbox '{0}' not found")]
SandboxNotFound(String),
#[error("invalid sandbox name: {0}")]
InvalidSandboxName(String),
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("protocol: {0}")]
Protocol(#[from] microsandbox_protocol::ProtocolError),
#[error(
"the sandbox runtime is too old for '{msg_type}' (needs protocol generation {needs}, the sandbox speaks {peer}); restart the sandbox to update its runtime"
)]
UnsupportedOperation {
msg_type: &'static str,
needs: u8,
peer: u8,
},
#[error("reader closed before response for id={0}")]
ReaderClosed(u32),
#[error("client closed")]
Closed,
}