pub struct Session { /* private fields */ }Expand description
An authenticated SSH connection to a device.
Session is Clone + Send + Sync — cloning is cheap (increments a
reference count). Use open_channel() to create
independent PTY shells on the same underlying SSH connection.
Obtain a Session via SessionBuilder::connect() or
GenericDriver::session().
Implementations§
Source§impl Session
impl Session
Sourcepub async fn open_channel(&self) -> Result<Channel>
pub async fn open_channel(&self) -> Result<Channel>
Open a new PTY channel on this session.
Each channel gets its own interactive shell, privilege state, and
pattern buffer. The channel waits for the initial prompt, executes
on_open_commands, and determines the initial privilege level before
returning.
Sourcepub fn platform(&self) -> &PlatformDefinition
pub fn platform(&self) -> &PlatformDefinition
Get the platform definition.
Sourcepub fn connected_since(&self) -> Instant
pub fn connected_since(&self) -> Instant
When this session was established.
Sourcepub fn prompt_patterns(&self) -> &[Regex]
pub fn prompt_patterns(&self) -> &[Regex]
Get the prompt patterns.
Sourcepub async fn disconnected(&self) -> DisconnectReason
pub async fn disconnected(&self) -> DisconnectReason
Wait until the session disconnects and return the reason.
If already disconnected, returns immediately. If the watch channel
is dropped without a reason, returns DisconnectReason::Closed.
Session is Clone (Arc-based), so callers can clone and move
into a tokio::spawn or tokio::select! branch.