Skip to main content

SshManager

Struct SshManager 

Source
pub struct SshManager { /* private fields */ }
Expand description

Entry point for all SSH management operations.

SshManager is cheaply Clone-able and safe to share across async tasks. Each subsystem is accessed via a dedicated accessor method (e.g. keys(), config()).

§Examples

use toride_ssh::SshManager;

let mgr = SshManager::new()?;
let keys = mgr.keys().list().await?;
println!("Found {} keys", keys.len());

Implementations§

Source§

impl SshManager

Source

pub fn new() -> Result<Self>

Create a new manager resolving ~/.ssh from the user’s home directory.

Uses DefaultCliRunner for all CLI operations. For tests, prefer with_cli_runner with a MockCliRunner.

§Errors

Returns Error::HomeNotFound if the user’s home directory cannot be resolved.

Source

pub fn with_cli_runner(runner: Arc<dyn CliRunner>) -> Result<Self>

Create a manager with a custom CliRunner.

This is the primary injection point for tests: pass a MockCliRunner to control command execution without spawning real SSH processes.

§Errors

Returns Error::HomeNotFound if the user’s home directory cannot be resolved.

§Examples
use std::sync::Arc;
use toride_ssh::{SshManager, MockCliRunner};

let mock = Arc::new(MockCliRunner::new());
mock.set_tool_exists("ssh-keygen", true);
let mgr = SshManager::with_cli_runner(mock)?;
Source

pub fn keys(&self) -> KeyService<'_>

Key management operations.

Source

pub fn config(&self) -> ConfigService<'_>

SSH config operations.

Source

pub fn agent(&self) -> AgentService<'_>

SSH agent operations.

Source

pub fn authorized_keys(&self) -> AuthorizedKeysService<'_>

authorized_keys management (listing, adding, removing keys).

Source

pub fn doctor(&self) -> DoctorService<'_>

Diagnostic checks.

Source

pub fn known_hosts(&self) -> KnownHostsService<'_>

Known hosts management (listing, scanning, adding, removing).

Source

pub fn forward(&self) -> ForwardService<'_>

Port forwarding management via ControlMaster.

Trait Implementations§

Source§

impl Clone for SshManager

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SshManager

Source§

fn default() -> Self

Return a best-effort manager using DefaultCliRunner.

Falls back to ~/.ssh if the home directory is unavailable.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more