Skip to main content

Remote

Struct Remote 

Source
pub struct Remote { /* private fields */ }

Implementations§

Source§

impl Remote

Source

pub fn new(cfg: RemoteConfig, limits: Limits) -> Self

Source

pub fn host(&self) -> &str

Source

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.

Source

pub fn workdir(&self) -> &str

The workdir as configured (~ not yet expanded).

Source

pub async fn effective_workdir(&self) -> Result<String>

The workdir with ~ expanded; connects if needed.

Source

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.

Source

pub fn limits(&self) -> &Limits

Source

pub fn configured_platform(&self) -> Option<Platform>

The platform as configured, before any connection: None for auto.

Source

pub async fn platform(&self) -> Result<Platform>

The detected platform; connects if needed.

Source

pub async fn connect(&self) -> Result<()>

Connect now, or report why that is impossible.

Source

pub async fn is_connected(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

pub async fn write_file(&self, path: &str, content: &[u8]) -> Result<String>

Write a whole file, creating parent directories.

Source

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.

Source

pub async fn file_size(&self, path: &str) -> Result<u64>

Size of the regular file at path (resolved here).

Source

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.

Source

pub async fn ensure_dir(&self, dir: &str) -> Result<()>

Create dir and any missing parents over SFTP. dir is a resolved native path.

Source

pub async fn exists(&self, path: &str) -> Result<Option<bool>>

Source

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.

Source

pub async fn has_tool(&self, name: &str) -> Result<bool>

Whether a remote executable is on PATH.

Auto Trait Implementations§

§

impl !Freeze for Remote

§

impl !RefUnwindSafe for Remote

§

impl !UnwindSafe for Remote

§

impl Send for Remote

§

impl Sync for Remote

§

impl Unpin for Remote

§

impl UnsafeUnpin for Remote

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more