Runner

Struct Runner 

Source
pub struct Runner<'a, CS: CliServ> { /* private fields */ }
Expand description

A SSH session instance

An application provides network or channel data to Runner method calls, and provides customisation callbacks via CliBehaviour or ServBehaviour.

Implementations§

Source§

impl<'a> Runner<'a, Client>

Source

pub fn new_client( inbuf: &'a mut [u8], outbuf: &'a mut [u8], ) -> Runner<'a, Client>

inbuf and outbuf must be sized to fit the largest SSH packet allowed.

Source§

impl<'a> Runner<'a, Server>

Source

pub fn new_server( inbuf: &'a mut [u8], outbuf: &'a mut [u8], ) -> Runner<'a, Server>

inbuf and outbuf must be sized to fit the largest SSH packet allowed.

Source§

impl<'a, CS: CliServ> Runner<'a, CS>

Source

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

Source

pub fn progress(&mut self) -> Result<Event<'_, 'a>>

Drives connection progress, handling received payload and queueing packets to send as required.

Source

pub fn input(&mut self, buf: &[u8]) -> Result<usize, Error>

Source

pub fn is_input_ready(&self) -> bool

Source

pub fn set_input_waker(&mut self, waker: &Waker)

Set a waker to be notified when input() is ready to be called.

Source

pub fn close_input(&mut self)

Indicate that the input SSH tcp socket has closed

Source

pub fn output(&mut self, buf: &mut [u8]) -> usize

Write any pending output to the wire, returning the size written

Source

pub fn output_buf(&mut self) -> &[u8]

Returns a buffer of output to send over the wire.

Call consume_output() to indicate how many bytes were used.

This is similar to `std::io::BufRead::fill_buf(), but an empty slice returned does not indicate EOF.

Source

pub fn consume_output(&mut self, l: usize)

Indicate how many bytes were taken from output_buf()

Source

pub fn is_output_pending(&self) -> bool

Source

pub fn set_output_waker(&mut self, waker: &Waker)

Set a waker to be notified when output() will have pending data

Source

pub fn close_output(&mut self)

Indicate that the output SSH tcp socket has closed

Source

pub fn open_client_session(&mut self) -> Result<ChanHandle>

Source

pub fn write_channel( &mut self, chan: &ChanHandle, dt: ChanData, buf: &[u8], ) -> Result<usize>

Send data from this application out the wire.

Returns Ok(len) consumed, Err(Error::ChannelEof) on EOF, or other errors.

Source

pub fn read_channel( &mut self, chan: &ChanHandle, dt: ChanData, buf: &mut [u8], ) -> Result<usize>

Receive data coming from the wire into this application.

Returns Ok(len) received, Err(Error::ChannelEof) on EOF, or other errors. Ok(0) indicates no data available, ie pending. TODO: EOF is unimplemented

Source

pub fn read_channel_either( &mut self, chan: &ChanHandle, buf: &mut [u8], ) -> Result<(usize, ChanData)>

Receives input data, either normal or extended.

Source

pub fn discard_read_channel(&mut self, chan: &ChanHandle) -> Result<()>

Discards any channel input data pending for chan, regardless of whether normal or extended.

Source

pub fn read_channel_ready(&self) -> Option<(ChanNum, ChanData, usize)>

Indicates when channel data is ready.

When channel data is ready, returns a tuple Some((channel, data, len)) len is the amount of data ready remaining to read, will always be non-zero. Note that this returns a ChanNum index rather than a ChanHandle (which would be owned by the caller already.

Returns None if no data ready.

Source

pub fn is_channel_eof(&self, chan: &ChanHandle) -> bool

Source

pub fn is_channel_closed(&self, chan: &ChanHandle) -> bool

Source

pub fn write_channel_ready( &self, chan: &ChanHandle, dt: ChanData, ) -> Result<Option<usize>>

Returns the maximum data that may be sent to a channel

Returns Ok(None) on channel closed.

May fail with BadChannelData if dt is invalid for this session.

Source

pub fn is_write_channel_valid(&self, chan: &ChanHandle, dt: ChanData) -> bool

Returns true if the channel and dt are currently valid for writing.

Note that they may not be ready to send output.

Source

pub fn channel_done(&mut self, chan: ChanHandle) -> Result<()>

Must be called when an application has finished with a channel.

Channel numbers will not be re-used without calling this, so failing to call this may result in running out of channels.

Source

pub fn term_window_change( &mut self, chan: &ChanHandle, winch: &WinChange, ) -> Result<()>

Send a terminal window size change report.

Only call on a client session with a pty

Source

pub fn term_break(&mut self, chan: &ChanHandle, length: u32) -> Result<()>

Send a break to a session channel

length is in milliseconds, or pass 0 as a default (to be interpreted by the remote implementation). Otherwise length will be clamped to the range [500, 3000] ms. Only call on a client session.

Trait Implementations§

Source§

impl<CS: CliServ> Debug for Runner<'_, CS>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, CS> Freeze for Runner<'a, CS>
where CS: Freeze,

§

impl<'a, CS> RefUnwindSafe for Runner<'a, CS>
where CS: RefUnwindSafe,

§

impl<'a, CS> Send for Runner<'a, CS>

§

impl<'a, CS> Sync for Runner<'a, CS>
where CS: Sync,

§

impl<'a, CS> Unpin for Runner<'a, CS>
where CS: Unpin,

§

impl<'a, CS> !UnwindSafe for Runner<'a, CS>

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.