use crate::portal::connection::Connection;
use crate::portal::interfaces::FilesInterface;
use crate::portal::interfaces::{ContainerInterface, ExecutionInterface, GuestInterface};
use boxlite_shared::{BoxliteResult, Transport};
#[derive(Clone)]
pub struct GuestSession {
connection: Connection,
}
impl GuestSession {
pub fn new(transport: Transport) -> Self {
Self {
connection: Connection::new(transport),
}
}
pub async fn execution(&self) -> BoxliteResult<ExecutionInterface> {
let channel = self.connection.channel().await?;
Ok(ExecutionInterface::new(channel))
}
pub async fn container(&self) -> BoxliteResult<ContainerInterface> {
let channel = self.connection.channel().await?;
Ok(ContainerInterface::new(channel))
}
pub async fn guest(&self) -> BoxliteResult<GuestInterface> {
let channel = self.connection.channel().await?;
Ok(GuestInterface::new(channel))
}
pub async fn files(&self) -> BoxliteResult<FilesInterface> {
let channel = self.connection.channel().await?;
Ok(FilesInterface::new(channel))
}
}
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
let _ = assert_send_sync::<GuestSession>;
};