ssh_agent_lib/proto/
error.rs

1//! Agent protocol errors.
2
3use std::{io, string};
4
5use thiserror::Error;
6
7/// SSH protocol error.
8#[derive(Debug, Error)]
9pub enum ProtoError {
10    /// Received string was not UTF-8 encoded.
11    #[error("String encoding failed: {0}")]
12    StringEncoding(#[from] string::FromUtf8Error),
13
14    /// Input/output error.
15    #[error("I/O Error: {0}")]
16    IO(#[from] io::Error),
17
18    /// Error decoding SSH structures.
19    #[error("SSH encoding error: {0}")]
20    SshEncoding(#[from] ssh_encoding::Error),
21
22    /// SSH key format error.
23    #[error("SSH key error: {0}")]
24    SshKey(#[from] ssh_key::Error),
25
26    /// SSH signature error.
27    #[error("SSH signature error: {0}")]
28    SshSignature(#[from] signature::Error),
29
30    /// Received command was not supported.
31    #[error("Command not supported ({command})")]
32    UnsupportedCommand {
33        /// Command code that was unsupported.
34        command: u8,
35    },
36
37    /// The client expected a different response.
38    #[error("Unexpected response received")]
39    UnexpectedResponse,
40}
41
42/// Protocol result.
43pub type ProtoResult<T> = Result<T, ProtoError>;