pub struct DeviceSession { /* private fields */ }Expand description
Manages an active SSH session to an Aurora device
This struct encapsulates the device connection and provides convenient methods for executing commands, both as regular user and as root via devel-su.
§Example
use audb::tools::session::DeviceSession;
use audb::tools::types::Device;
let mut session = DeviceSession::connect(&device).await?;
let output = session.exec("uname -a").await?;
println!("System info: {:?}", output);Implementations§
Source§impl DeviceSession
impl DeviceSession
Sourcepub fn connect(device: &Device) -> Result<Self, DeviceError>
pub fn connect(device: &Device) -> Result<Self, DeviceError>
Sourcepub fn exec_as_root(
&mut self,
command: &str,
) -> Result<Vec<String>, DeviceError>
pub fn exec_as_root( &mut self, command: &str, ) -> Result<Vec<String>, DeviceError>
Execute command as root via devel-su
This method uses the device’s configured root password to execute commands with root privileges using Aurora OS’s devel-su mechanism.
§Arguments
command- The shell command to execute as root
§Returns
A vector of output lines (stdout) from the command
§Errors
- Returns
DeviceError::RootPasswordNotConfiguredif no root password is set - Returns an error if command execution fails
§Security
The password and command are properly escaped to prevent shell injection.
Sourcepub fn read_file_base64(
&mut self,
remote_path: &Path,
) -> Result<String, DeviceError>
pub fn read_file_base64( &mut self, remote_path: &Path, ) -> Result<String, DeviceError>
Read remote file contents as base64 string
This method is useful for reading files that may be owned by root, as it uses the root password if configured.
§Arguments
remote_path- Path to the file on the remote device
§Returns
Base64-encoded contents of the file
§Errors
- Returns
DeviceError::RootPasswordNotConfiguredif no root password is set - Returns an error if file reading fails
Sourcepub fn device_name(&self) -> String
pub fn device_name(&self) -> String
Get the device’s display name
Auto Trait Implementations§
impl Freeze for DeviceSession
impl !RefUnwindSafe for DeviceSession
impl Send for DeviceSession
impl Sync for DeviceSession
impl Unpin for DeviceSession
impl !UnwindSafe for DeviceSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more