support_kit/hosts/
host_session.rs1use crate::SshError;
2
3use super::{HostDetails, SshSession};
4
5pub struct HostSession {
6 _config: HostDetails,
7 session: SshSession,
8}
9
10#[bon::bon]
11impl HostSession {
12 #[builder]
13 #[tracing::instrument(skip(host), level = "trace")]
14 pub async fn connect(#[builder(into)] host: HostDetails) -> Result<Self, SshError> {
15 Ok(Self {
16 session: SshSession::connect(&host).await?,
17 _config: host,
18 })
19 }
20
21 #[tracing::instrument(skip(self, cmd), level = "trace")]
22 pub async fn run_cmd<T>(&self, cmd: Vec<T>) -> Result<(), SshError>
23 where
24 T: AsRef<str>,
25 {
26 self.session.run_cmd(cmd).await
27 }
28}