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, CS: CliServ> Runner<'a, CS>
impl<'a, CS: CliServ> Runner<'a, CS>
pub fn new(inbuf: &'a mut [u8], outbuf: &'a mut [u8]) -> Runner<'a, CS>
Sourcepub fn progress(&mut self) -> Result<Event<'_, 'a>>
pub fn progress(&mut self) -> Result<Event<'_, 'a>>
Drives connection progress, handling received payload and queueing packets to send as required.
pub fn input(&mut self, buf: &[u8]) -> Result<usize, Error>
pub fn is_input_ready(&self) -> bool
Sourcepub fn set_input_waker(&mut self, waker: &Waker)
pub fn set_input_waker(&mut self, waker: &Waker)
Set a waker to be notified when input() is ready to be called.
Sourcepub fn close_input(&mut self)
pub fn close_input(&mut self)
Indicate that the input SSH tcp socket has closed
Sourcepub fn output(&mut self, buf: &mut [u8]) -> usize
pub fn output(&mut self, buf: &mut [u8]) -> usize
Write any pending output to the wire, returning the size written
Sourcepub fn output_buf(&mut self) -> &[u8]
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.
Sourcepub fn consume_output(&mut self, l: usize)
pub fn consume_output(&mut self, l: usize)
Indicate how many bytes were taken from output_buf()
pub fn is_output_pending(&self) -> bool
Sourcepub fn set_output_waker(&mut self, waker: &Waker)
pub fn set_output_waker(&mut self, waker: &Waker)
Set a waker to be notified when output() will have pending data
Sourcepub fn close_output(&mut self)
pub fn close_output(&mut self)
Indicate that the output SSH tcp socket has closed
pub fn open_client_session(&mut self) -> Result<ChanHandle>
Sourcepub fn write_channel(
&mut self,
chan: &ChanHandle,
dt: ChanData,
buf: &[u8],
) -> Result<usize>
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.
Sourcepub fn read_channel(
&mut self,
chan: &ChanHandle,
dt: ChanData,
buf: &mut [u8],
) -> Result<usize>
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
Sourcepub fn read_channel_either(
&mut self,
chan: &ChanHandle,
buf: &mut [u8],
) -> Result<(usize, ChanData)>
pub fn read_channel_either( &mut self, chan: &ChanHandle, buf: &mut [u8], ) -> Result<(usize, ChanData)>
Receives input data, either normal or extended.
Sourcepub fn discard_read_channel(&mut self, chan: &ChanHandle) -> Result<()>
pub fn discard_read_channel(&mut self, chan: &ChanHandle) -> Result<()>
Discards any channel input data pending for chan, regardless of whether
normal or extended.
Sourcepub fn read_channel_ready(&self) -> Option<(ChanNum, ChanData, usize)>
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.
pub fn is_channel_eof(&self, chan: &ChanHandle) -> bool
pub fn is_channel_closed(&self, chan: &ChanHandle) -> bool
Sourcepub fn write_channel_ready(
&self,
chan: &ChanHandle,
dt: ChanData,
) -> Result<Option<usize>>
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.
Sourcepub fn is_write_channel_valid(&self, chan: &ChanHandle, dt: ChanData) -> bool
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.
Sourcepub fn channel_done(&mut self, chan: ChanHandle) -> Result<()>
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.
Sourcepub fn term_window_change(
&mut self,
chan: &ChanHandle,
winch: &WinChange,
) -> Result<()>
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
Sourcepub fn term_break(&mut self, chan: &ChanHandle, length: u32) -> Result<()>
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.