[][src]Struct thrussh::client::Connection

pub struct Connection<R: AsyncRead + AsyncWrite, H: Handler> { /* fields omitted */ }

Client connection. A connection implements Future, returning () when it finishes (for instance if the client and server agree to close the connection).

Methods

impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>[src]

pub fn channel_close(&mut self, channel: ChannelId)[src]

Ask the server to close a channel, finishing any pending write and read.

pub fn handler(&self) -> &H[src]

Gets a borrow to the connection's handler.

pub fn handler_mut(&mut self) -> &mut H[src]

Gets a mutable borrow to the connection's handler.

pub fn is_channel_open(&self, channel: ChannelId) -> bool[src]

Tests whether a channel is open.

pub fn new(
    config: Arc<Config>,
    stream: R,
    handler: H,
    timeout: Option<Delay>
) -> Result<Self, Error>
[src]

Create a new client connection.

impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>[src]

pub fn data<T: AsRef<[u8]>>(
    self,
    channel: ChannelId,
    extended: Option<u32>,
    data: T
) -> Data<R, H, T>
[src]

Send data to a channel. On session channels, extended can be used to encode standard error by passing Some(1), and stdout by passing None.

impl<R: AsyncRead + AsyncWrite + Tcp, H: Handler> Connection<R, H>[src]

pub fn authenticate_password(
    self,
    user: &str,
    password: String
) -> Authenticate<R, H>
[src]

Try to authenticate this client using a password.

pub fn authenticate_key(
    self,
    user: &str,
    key: Arc<KeyPair>
) -> Authenticate<R, H>
[src]

Try to authenticate this client using a key pair.

pub fn authenticate_key_future(
    self,
    user: &str,
    key: PublicKey
) -> Authenticate<R, H>
[src]

Try to authenticate this client using a key pair.

impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>[src]

pub fn channel_open_session(self) -> ChannelOpen<R, H, SessionChannel>[src]

Ask the server to open a session channel.

pub fn channel_open_x11(
    self,
    originator_address: &str,
    originator_port: u32
) -> ChannelOpen<R, H, X11Channel>
[src]

Ask the server to open an X11 forwarding channel.

pub fn channel_open_direct_tcpip(
    self,
    host_to_connect: &str,
    port_to_connect: u32,
    originator_address: &str,
    originator_port: u32
) -> ChannelOpen<R, H, DirectTcpIpChannel>
[src]

Ask the server to open a direct TCP/IP forwarding channel.

impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>[src]

pub fn wait<F: Fn(&Connection<R, H>) -> bool>(self, f: F) -> Wait<R, H, F>[src]

Wait until a condition is met on the connection.

pub fn wait_flush(self) -> WaitFlush<R, H>[src]

Flush the session, sending any pending message.

Methods from Deref<Target = Session>

pub fn flush(&mut self) -> Result<(), Error>[src]

Flush the temporary cleartext buffer into the encryption buffer. This does not flush to the socket.

pub fn config(&self) -> &Config[src]

Retrieves the configuration of this session.

pub fn auth_user(&self) -> &str[src]

Retrieves the current user.

pub fn disconnect(
    &mut self,
    reason: Disconnect,
    description: &str,
    language_tag: &str
)
[src]

Sends a disconnect message.

pub fn is_authenticated(&self) -> bool[src]

Whether the client is authenticated.

pub fn is_disconnected(&self) -> bool[src]

Whether the client is disconnected.

pub fn channel_is_open(&self, channel: ChannelId) -> bool[src]

Check whether a channel has been confirmed.

pub fn has_auth_method(&self) -> bool[src]

Tests whether we need an authentication method (for instance if the last attempt failed).

pub fn valid_auth_methods(&self) -> Option<MethodSet>[src]

Returns the set of authentication methods that can continue, or None if this is not valid.

pub fn channel_open_session(&mut self) -> Result<ChannelId, Error>[src]

Request a session channel (the most basic type of channel). This function returns Some(..) immediately if the connection is authenticated, but the channel only becomes usable when it's confirmed by the server, as indicated by the confirmed field of the corresponding Channel.

pub fn channel_open_x11(
    &mut self,
    originator_address: &str,
    originator_port: u32
) -> Result<ChannelId, Error>
[src]

Request an X11 channel, on which the X11 protocol may be tunneled.

pub fn channel_open_direct_tcpip(
    &mut self,
    host_to_connect: &str,
    port_to_connect: u32,
    originator_address: &str,
    originator_port: u32
) -> Result<ChannelId, Error>
[src]

Open a TCP/IP forwarding channel. This is usually done when a connection comes to a locally forwarded TCP/IP port. See RFC4254. The TCP/IP packets can then be tunneled through the channel using .data().

pub fn channel_eof(&mut self, channel: ChannelId)[src]

Send EOF to a channel

pub fn request_pty(
    &mut self,
    channel: ChannelId,
    want_reply: bool,
    term: &str,
    col_width: u32,
    row_height: u32,
    pix_width: u32,
    pix_height: u32,
    terminal_modes: &[(Pty, u32)]
)
[src]

Request a pseudo-terminal with the given characteristics.

pub fn request_x11(
    &mut self,
    channel: ChannelId,
    want_reply: bool,
    single_connection: bool,
    x11_authentication_protocol: &str,
    x11_authentication_cookie: &str,
    x11_screen_number: u32
)
[src]

Request X11 forwarding through an already opened X11 channel. See RFC4254 for security issues related to cookies.

pub fn set_env(
    &mut self,
    channel: ChannelId,
    want_reply: bool,
    variable_name: &str,
    variable_value: &str
)
[src]

Set a remote environment variable.

pub fn request_shell(&mut self, want_reply: bool, channel: ChannelId)[src]

Request a remote shell.

pub fn exec(&mut self, channel: ChannelId, want_reply: bool, command: &str)[src]

Execute a remote program (will be passed to a shell). This can be used to implement scp (by calling a remote scp and tunneling to its standard input).

pub fn signal(&mut self, channel: ChannelId, signal: Sig)[src]

Signal a remote process.

pub fn request_subsystem(
    &mut self,
    want_reply: bool,
    channel: ChannelId,
    name: &str
)
[src]

Request the start of a subsystem with the given name.

pub fn window_change(
    &mut self,
    channel: ChannelId,
    col_width: u32,
    row_height: u32,
    pix_width: u32,
    pix_height: u32
)
[src]

Inform the server that our window size has changed.

pub fn tcpip_forward(&mut self, want_reply: bool, address: &str, port: u32)[src]

Request the forwarding of a remote port to the client. The server will then open forwarding channels (which cause the client to call .channel_open_forwarded_tcpip()).

pub fn cancel_tcpip_forward(
    &mut self,
    want_reply: bool,
    address: &str,
    port: u32
)
[src]

Cancel a previous forwarding request.

pub fn data(
    &mut self,
    channel: ChannelId,
    extended: Option<u32>,
    data: &[u8]
) -> usize
[src]

Send data to a channel. The number of bytes added to the "sending pipeline" (to be processed by the event loop) is returned.

Trait Implementations

impl<R: AsyncRead + AsyncWrite + Sync, H: Handler + Sync> Sync for Connection<R, H>[src]

impl<R: AsyncRead + AsyncWrite + Send, H: Handler + Send> Send for Connection<R, H>[src]

impl<R: AsyncRead + AsyncWrite, H: Handler> DerefMut for Connection<R, H>[src]

impl<R: AsyncRead + AsyncWrite, H: Handler> Deref for Connection<R, H>[src]

type Target = Session

The resulting type after dereferencing.

impl<R: AsyncRead + AsyncWrite + Tcp, H: Handler> Future for Connection<R, H>[src]

type Item = ()

The type of value that this future will resolved with if it is successful. Read more

type Error = HandlerError<H::Error>

The type of error that this future will resolve with if it fails in a normal fashion. Read more

fn wait(self) -> Result<Self::Item, Self::Error>[src]

Block the current thread until this future is resolved. Read more

fn map<F, U>(self, f: F) -> Map<Self, F> where
    F: FnOnce(Self::Item) -> U, 
[src]

Map this future's result to a different type, returning a new future of the resulting type. Read more

fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where
    F: FnOnce(Self::Error) -> E, 
[src]

Map this future's error to a different error, returning a new future. Read more

fn from_err<E>(self) -> FromErr<Self, E> where
    E: From<Self::Error>, 
[src]

Map this future's error to any error implementing From for this future's Error, returning a new future. Read more

fn then<F, B>(self, f: F) -> Then<Self, B, F> where
    B: IntoFuture,
    F: FnOnce(Result<Self::Item, Self::Error>) -> B, 
[src]

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more

fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where
    B: IntoFuture<Error = Self::Error>,
    F: FnOnce(Self::Item) -> B, 
[src]

Execute another future after this one has resolved successfully. Read more

fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F> where
    B: IntoFuture<Item = Self::Item>,
    F: FnOnce(Self::Error) -> B, 
[src]

Execute another future if this one resolves with an error. Read more

fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future> where
    B: IntoFuture<Item = Self::Item, Error = Self::Error>, 
[src]

Waits for either one of two futures to complete. Read more

fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future> where
    B: IntoFuture
[src]

Waits for either one of two differently-typed futures to complete. Read more

fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>, 
[src]

Joins the result of two futures, waiting for them both to complete. Read more

fn join3<B, C>(
    self,
    b: B,
    c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>,
    C: IntoFuture<Error = Self::Error>, 
[src]

Same as join, but with more futures.

fn join4<B, C, D>(
    self,
    b: B,
    c: C,
    d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>,
    C: IntoFuture<Error = Self::Error>,
    D: IntoFuture<Error = Self::Error>, 
[src]

Same as join, but with more futures.

fn join5<B, C, D, E>(
    self,
    b: B,
    c: C,
    d: D,
    e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>,
    C: IntoFuture<Error = Self::Error>,
    D: IntoFuture<Error = Self::Error>,
    E: IntoFuture<Error = Self::Error>, 
[src]

Same as join, but with more futures.

fn into_stream(self) -> IntoStream<Self>[src]

Convert this future into a single element stream. Read more

fn flatten(self) -> Flatten<Self> where
    Self::Item: IntoFuture,
    <Self::Item as IntoFuture>::Error: From<Self::Error>, 
[src]

Flatten the execution of this future when the successful result of this future is itself another future. Read more

fn flatten_stream(self) -> FlattenStream<Self> where
    Self::Item: Stream,
    <Self::Item as Stream>::Error == Self::Error
[src]

Flatten the execution of this future when the successful result of this future is a stream. Read more

fn fuse(self) -> Fuse<Self>[src]

Fuse a future such that poll will never again be called once it has completed. Read more

fn inspect<F>(self, f: F) -> Inspect<Self, F> where
    F: FnOnce(&Self::Item), 
[src]

Do something with the item of a future, passing it on. Read more

fn catch_unwind(self) -> CatchUnwind<Self> where
    Self: UnwindSafe
[src]

Catches unwinding panics while polling the future. Read more

fn shared(self) -> Shared<Self>[src]

Create a cloneable handle to this future where all handles will resolve to the same result. Read more

Auto Trait Implementations

impl<R, H> Unpin for Connection<R, H> where
    H: Unpin,
    R: Unpin,
    <H as Handler>::FutureBool: Unpin,
    <H as Handler>::FutureSign: Unpin,
    <H as Handler>::SessionUnit: Unpin

impl<R, H> !RefUnwindSafe for Connection<R, H>

impl<R, H> !UnwindSafe for Connection<R, H>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Future = F

The future that this type can be converted into.

type Item = <F as Future>::Item

The item that the future may resolve with.

type Error = <F as Future>::Error

The error that the future may resolve with.

impl<T> FutureExt for T where
    T: Future + ?Sized
[src]

fn timeout(self, timeout: Duration) -> Timeout<Self>[src]

Creates a new future which allows self until timeout. Read more

impl<T> Erased for T