Struct SSHServer

Source
pub struct SSHServer<'a> { /* private fields */ }
Expand description

An async SSH server instance

The run() method runs the session to completion. progress() must be polled, and responses given to the events provided.

Once the client has opened sessions, those can be retrieved with stdio() and stdio_stderr() methods.

This is async executor agnostic.

Implementations§

Source§

impl<'a> SSHServer<'a>

Source

pub fn new(inbuf: &'a mut [u8], outbuf: &'a mut [u8]) -> Self

Source

pub async fn run( &self, rsock: &mut impl Read, wsock: &mut impl Write, ) -> Result<()>

Runs the session to completion.

rsock and wsock are the SSH network channel (TCP port 22 or equivalent).

Source

pub async fn progress<'g, 'f>( &'g self, ph: &'f mut ProgressHolder<'g, 'a, Server>, ) -> Result<ServEvent<'f, 'a>>

Returns an event from the SSH session.

Note that on return ProgressHolder holds a mutex over the session, so most other calls to SSHServer will block until the ProgressHolder is dropped.

Source

pub async fn stdio(&self, ch: ChanHandle) -> Result<ChanInOut<'_>>

Returns a ChanInOut representing a channel.

For a shell this is stdin/stdout, for other channel types it is the only data type. ch is the ChanHandle returned after accepting a ServEvent::OpenSession event.

Source

pub async fn stdio_stderr( &self, ch: ChanHandle, ) -> Result<(ChanInOut<'_>, ChanOut<'_>)>

Retrieve the stdin/stdout/stderr streams.

If stderr is not required, use stdio() instead to avoid needing to poll the returned stderr. The session will block until the streams are drained (they use the session buffer), so they must be drained if used.

Trait Implementations§

Source§

impl<'a> Debug for SSHServer<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for SSHServer<'a>

§

impl<'a> !RefUnwindSafe for SSHServer<'a>

§

impl<'a> Send for SSHServer<'a>

§

impl<'a> !Sync for SSHServer<'a>

§

impl<'a> Unpin for SSHServer<'a>

§

impl<'a> !UnwindSafe for SSHServer<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.