partition_sim/commands/
mod.rs

1mod fs;
2mod ip;
3mod ssh;
4
5pub use fs::FsCommands;
6pub use ip::IpTablesCommands;
7pub use ssh::SshCommands;
8
9/// A command should be able to build itself into an `openssh::Command`, given
10/// an `openssh::Session`.
11pub trait Command {
12    /// Build the command.
13    fn build<'session>(&self, session: &'session openssh::Session) -> openssh::Command<'session>;
14}
15
16/// A wrapper around all commands.
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub enum Commands {
19    /// All `iptables` related commands.
20    IpTables(IpTablesCommands),
21    /// All file-system related commands.
22    Fs(FsCommands),
23}
24
25impl Command for Commands {
26    fn build<'session>(&self, session: &'session openssh::Session) -> openssh::Command<'session> {
27        match self {
28            Self::IpTables(command) => command.build(session),
29            Self::Fs(command) => command.build(session),
30        }
31    }
32}