Struct ssh2::Channel [] [src]

pub struct Channel<'sess> { /* fields omitted */ }

A channel represents a portion of an SSH connection on which data can be read and written.

Channels denote all of SCP uploads and downloads, shell sessions, remote process executions, and other general-purpose sessions. Each channel implements the Reader and Writer traits to send and receive data. Whether or not I/O operations are blocking is mandated by the blocking flag on a channel's corresponding Session.

Methods

impl<'sess> Channel<'sess>
[src]

Set an environment variable in the remote channel's process space.

Note that this does not make sense for all channel types and may be ignored by the server despite returning success.

Request a PTY on an established channel.

Note that this does not make sense for all channel types and may be ignored by the server despite returning success.

The dimensions argument is a tuple of (width, height, width_px, height_px)

Request a PTY of a specified size

Execute a command

An execution is one of the standard process services defined by the SSH2 protocol.

Example

let mut channel = session.channel_session().unwrap();
channel.exec("ls").unwrap();
let mut s = String::new();
channel.read_to_string(&mut s).unwrap();
println!("{}", s);

Start a shell

A shell is one of the standard process services defined by the SSH2 protocol.

Request a subsystem be started.

A subsystem is one of the standard process services defined by the SSH2 protocol.

Initiate a request on a session type channel.

The SSH2 protocol currently defines shell, exec, and subsystem as standard process services.

Get a handle to the stderr stream of this channel.

The returned handle implements the Read and Write traits.

Get a handle to a particular stream for this channel.

The returned handle implements the Read and Write traits.

Groups of substreams may be flushed by passing on of the following constants and then calling flush().

  • FLUSH_EXTENDED_DATA - Flush all extended data substreams
  • FLUSH_ALL - Flush all substreams

Returns the exit code raised by the process running on the remote host at the other end of the named channel.

Note that the exit status may not be available if the remote end has not yet set its status to closed.

Get the remote exit signal.

Check the status of the read window.

Check the status of the write window.

Adjust the receive window for a channel by adjustment bytes.

If the amount to be adjusted is less than the minimum adjustment and force is false, the adjustment amount will be queued for a later packet.

This function returns the new size of the receive window (as understood by remote end) on success.

Check if the remote host has sent an EOF status for the selected stream.

Tell the remote host that no further data will be sent on the specified channel.

Processes typically interpret this as a closed stdin descriptor.

Wait for the remote end to send EOF.

Close an active data channel.

In practice this means sending an SSH_MSG_CLOSE packet to the remote host which serves as instruction that no further data will be sent to it. The remote host may still send data back until it sends its own close message in response.

To wait for the remote end to close its connection as well, follow this command with wait_closed

Enter a temporary blocking state until the remote host closes the named channel.

Typically sent after close in order to examine the exit status.

Trait Implementations

impl<'sess> Write for Channel<'sess>
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more

impl<'sess> Read for Channel<'sess>
[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a "by reference" adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Unstable (io)

: the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an Iterator over chars. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

impl<'sess> Drop for Channel<'sess>
[src]

A method called when the value goes out of scope. Read more