← ssh · version 0.1.4
11 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.
pub struct Session { handle: integer }
A live SSH session. handle >= 0 once the TCP connect + transport handshake succeed; < 0 means the connect failed. Obtain one from connect.
pub fn byte_at(idx: integer, data: text) -> integer
Read the byte at idx (0..size) of a recv result. A terminal stream is raw bytes, so read it byte-by-byte rather than as UTF-8. Out of range returns -1 — not 0, which the stream itself may legitimately carry.
pub fn connect(host: text, port: integer) -> Session
Open a TCP connection to host:port and run the SSH transport handshake. Check ok() before authenticating.
pub fn ok(self: Session) -> boolean
True when the session connected and completed the transport handshake.
pub fn login(self: Session, user: text, password: text) -> boolean
Authenticate with a password. Returns true on success. The password is used only for this handshake and is never stored by the library.
pub fn open_shell(self: Session, term: text, cols: integer, rows: integer) -> boolean
Request a pseudo-terminal of cols x rows (terminal type term, e.g. "xterm-256color") and start the login shell. Returns true on success.
pub fn send(self: Session, data: text)
Send bytes to the remote shell (keystrokes, escape sequences). Binary-safe.
pub fn recv(self: Session) -> text
Return the bytes the remote shell produced since the last call, or "" when nothing is pending (non-blocking). Binary-safe: iterate 0..size(result) and read each byte with byte_at — size is the BYTE count, which is what byte_at is indexed against; len counts characters and would truncate.
pub fn resize(self: Session, cols: integer, rows: integer)
Tell the remote the terminal resized to cols x rows so it re-flows. Call after a zoom / rotate / window resize.
pub fn is_open(self: Session) -> boolean
True while the shell channel is open (the remote has not closed it).
pub fn close(self: Session)
Close the shell channel and disconnect.