pub struct Remote { /* private fields */ }Implementations§
Source§impl Remote
impl Remote
Sourcepub async fn spawn(&self, command: &str, cwd: Option<&str>) -> Result<Job>
pub async fn spawn(&self, command: &str, cwd: Option<&str>) -> Result<Job>
Start command in the background, in cwd (default: the workdir),
detached from the SSH session. Returns the job as recorded.
Source§impl Remote
impl Remote
pub fn new(cfg: RemoteConfig, limits: Limits) -> Self
pub fn host(&self) -> &str
Sourcepub fn address(&self) -> Address
pub fn address(&self) -> Address
How the remote is addressed from this machine, as OpenSSH resolves
the destination: (hostname, port). The model needs this to report
URLs the user can open; an alias from ~/.ssh/config means nothing
to a browser. Falls back to the configured destination.
Sourcepub async fn effective_workdir(&self) -> Result<String>
pub async fn effective_workdir(&self) -> Result<String>
The workdir with ~ expanded; connects if needed.
Sourcepub async fn workdir_created(&self) -> Result<bool>
pub async fn workdir_created(&self) -> Result<bool>
Whether the workdir was missing and got created when the current connection was made; connects if needed.
pub fn limits(&self) -> &Limits
Sourcepub fn configured_platform(&self) -> Option<Platform>
pub fn configured_platform(&self) -> Option<Platform>
The platform as configured, before any connection: None for
auto.
pub async fn is_connected(&self) -> bool
Sourcepub async fn resolve(&self, raw: &str) -> Result<String>
pub async fn resolve(&self, raw: &str) -> Result<String>
Absolute remote path, in the remote’s native form, for what the
model typed: ~ expands to the remote home, relative paths hang off
the working directory. / and \ are both accepted on Windows.
Sourcepub async fn exec(
&self,
command: &str,
cwd: Option<&str>,
timeout_secs: Option<u64>,
) -> Result<ExecOutput>
pub async fn exec( &self, command: &str, cwd: Option<&str>, timeout_secs: Option<u64>, ) -> Result<ExecOutput>
Run command in cwd (default: the working directory) through the
configured shell — PowerShell on Windows. timeout_secs is clamped
to the configured maximum.
Sourcepub async fn home(&self) -> Result<String>
pub async fn home(&self) -> Result<String>
The remote user’s home, native form; connects if needed.
Sourcepub async fn read_file(&self, path: &str, max: usize) -> Result<(Vec<u8>, u64)>
pub async fn read_file(&self, path: &str, max: usize) -> Result<(Vec<u8>, u64)>
Read at most max bytes of a remote file. Returns the bytes and the
file’s full length.
Sourcepub async fn write_file(&self, path: &str, content: &[u8]) -> Result<String>
pub async fn write_file(&self, path: &str, content: &[u8]) -> Result<String>
Write a whole file, creating parent directories.
Sourcepub async fn upload_file(
&self,
src: File,
dest: &str,
scan: StreamGuard<'_>,
max: u64,
) -> Result<(String, u64)>
pub async fn upload_file( &self, src: File, dest: &str, scan: StreamGuard<'_>, max: u64, ) -> Result<(String, u64)>
Copy the open local file src to dest (resolved here, parents
created), streaming it in TRANSFER_CHUNK pieces with up to
UPLOAD_WINDOW bytes unacknowledged. Every piece passes scan
before it is written, so what arrives is exactly what the guard saw,
and no more than max bytes are sent. Returns the native remote
path and the byte count. A failed upload removes what it left behind.
Sourcepub async fn file_size(&self, path: &str) -> Result<u64>
pub async fn file_size(&self, path: &str) -> Result<u64>
Size of the regular file at path (resolved here).
Sourcepub async fn download_into(
&self,
path: &str,
out: &Arc<File>,
max: u64,
) -> Result<u64>
pub async fn download_into( &self, path: &str, out: &Arc<File>, max: u64, ) -> Result<u64>
Copy the remote file at path (resolved here) into out, using
DOWNLOAD_STREAMS readers that each claim DOWNLOAD_STEP ranges in
turn and write through the one handle. The size is taken once, here,
and nothing past it is read: a file over max bytes by now is
refused before anything is allocated. Returns the byte count.
Sourcepub async fn ensure_dir(&self, dir: &str) -> Result<()>
pub async fn ensure_dir(&self, dir: &str) -> Result<()>
Create dir and any missing parents over SFTP. dir is a resolved
native path.
pub async fn exists(&self, path: &str) -> Result<Option<bool>>
Sourcepub async fn walk_files(&self, dir: &str, limit: usize) -> Result<Vec<String>>
pub async fn walk_files(&self, dir: &str, limit: usize) -> Result<Vec<String>>
Every regular file under dir (a resolved native path), as native
paths, over SFTP. Symlinks are not followed. Stops after limit
entries so a huge tree is refused quickly rather than listed.
Sourcepub async fn list_files(&self, dir: &str) -> Result<Vec<String>>
pub async fn list_files(&self, dir: &str) -> Result<Vec<String>>
The names of the regular files directly in dir (a resolved native
path), over SFTP; none if dir does not exist.
Sourcepub async fn has_tool(&self, name: &str) -> Result<bool>
pub async fn has_tool(&self, name: &str) -> Result<bool>
Whether a remote executable is on PATH.
Mount points of read-write virtiofs file systems on a POSIX
remote. That is how a microVM such as a Docker sandbox passes a host
folder straight through: whatever is written under one lands on the
host’s disk at once, past every check download makes. Empty on
Windows and where /proc/mounts does not exist.