ssh_muxcontrol/
lib.rs

1#![forbid(unsafe_code)]
2
3use std::fmt;
4
5mod commands;
6mod session;
7
8pub use commands::CommandError;
9pub use session::{run, run_stdin, MuxError, ShellResult};
10
11/// Error returned by ssh-muxcontrol library.
12#[derive(Debug)]
13pub enum SshctlError {
14    CommandError(CommandError),
15    MuxError(MuxError),
16    IoError(std::io::Error),
17}
18
19impl From<CommandError> for SshctlError {
20    fn from(err: CommandError) -> Self {
21        SshctlError::CommandError(err)
22    }
23}
24
25impl From<MuxError> for SshctlError {
26    fn from(err: MuxError) -> Self {
27        SshctlError::MuxError(err)
28    }
29}
30
31impl From<std::io::Error> for SshctlError {
32    fn from(err: std::io::Error) -> Self {
33        SshctlError::IoError(err)
34    }
35}
36
37impl fmt::Display for SshctlError {
38    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
39        match &self {
40            Self::CommandError(e) => write!(f, "CommandError: {}", e),
41            Self::MuxError(e) => write!(f, "MuxError: {}", e),
42            Self::IoError(e) => write!(f, "IoError: {}", e),
43        }
44    }
45}
46
47#[cfg(test)]
48mod tests;