pub struct Remote { /* private fields */ }Implementations§
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 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,
local: &Path,
dest: &str,
) -> Result<(String, u64)>
pub async fn upload_file( &self, local: &Path, dest: &str, ) -> Result<(String, u64)>
Copy the local file at local to dest (resolved here, parents
created), streaming it in TRANSFER_CHUNK pieces with up to
UPLOAD_WINDOW bytes unacknowledged. 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_file(&self, path: &str, dest: &Path) -> Result<u64>
pub async fn download_file(&self, path: &str, dest: &Path) -> Result<u64>
Copy the remote file at path (resolved here) to the local dest,
using DOWNLOAD_STREAMS readers that each claim DOWNLOAD_STEP
ranges in turn. The data lands in a .farhand-part file next to
dest and is renamed into place once complete, so an interrupted
download leaves nothing that looks finished. 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.