Skip to main content

Remote

Struct Remote 

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

Another machine, reached through a transport (see the module docs). Its paths are that machine’s: absolute, or under ~, its user’s home; a relative path is relative to that home, where the transport starts. Paths are folded without asking the machine (canonical), so links there are not followed.

Implementations§

Source§

impl Remote

Source

pub fn new( name: impl Into<String>, transport: impl IntoIterator<Item = impl Into<OsString>>, launcher: Launcher, ) -> Result<Self>

The machine name, such as bench, reached through transport, such as ["ssh", "dev@box"], which file operations start under launcher’s policy (its wrapper and variables; not its directory).

§Errors

An InvalidInput error when name is empty or holds a :, / or space, or transport is empty.

Source

pub fn name(&self) -> &str

Its name.

Trait Implementations§

Source§

impl Clone for Remote

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Remote

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Workspace for Remote

Source§

fn host(&self) -> Option<&str>

Its name.

Source§

fn excerpt(&self, path: &Path, first: usize, count: usize) -> Result<Excerpt>

One script that sends the file’s size, its line count, its hash and only the lines asked, or the whole file when it is at most MAX_BYTES, all of a copy made aside first, so they agree when the file changes meanwhile. A machine with neither sha256sum nor shasum sends a larger file whole in a second call, to hash it here.

Source§

fn read_files(&self, paths: &[PathBuf], limit: u64) -> Vec<Option<Vec<u8>>>

The files in scripts of 100 each, every file copied aside before it is sent, so one that changes meanwhile is sent whole as it was.

Source§

fn write(&self, path: &Path, bytes: &[u8]) -> Result<()>

replaces it, sending back nothing of what it held.

Source§

fn replace( &self, path: &Path, bytes: &[u8], limit: u64, ) -> Result<Result<Contents>>

Writes a temporary file beside it and moves it over the file, so a lost connection never leaves it half written, keeping an existing file’s permissions; the copy the temporary file starts as is what is sent back, in the same call.

Source§

fn write_if( &self, path: &Path, bytes: &[u8], held: &ContentHash, ) -> Result<Option<Contents>>

One script: a copy of the file is made beside it and hashed there, then filled with bytes and moved over the file when the hash is held, or sent back when it is not. A machine with neither sha256sum nor shasum always sends it back.

Source§

fn canonical(&self, path: &Path) -> PathBuf

Folds . and .. without asking the machine, a relative path under ~; a .. above ~ stays, as the remote sh reads it.

Source§

fn files( &self, root: &Path, glob: Option<&str>, listing: Listing, ) -> Result<Vec<PathBuf>>

As git lists them there in a git work tree (unless listing is All), else as find does, then filtered by Listing::keeps and glob.

Source§

fn spawn( &self, launcher: &Launcher, dir: Option<&Path>, program: &OsStr, args: &[OsString], how: Spawn, ) -> Result<Process>

Runs program there in dir (None: the remote home) with sh -l, so the remote user’s login environment holds, and the launcher’s variables, from a local transport started under the launcher’s wrapper (the launcher’s directory is this machine’s, so it is not used). The process is marked through this host: stopping it stops the local transport (SIGTERM, then SIGKILL), and whether that stops the command there is the transport’s to say.

Source§

fn stat(&self, path: &Path) -> Result<Stat>

What path is, its links followed: a file (its size, whether it is read-only, when it was last changed), a directory, something else, or nothing.
Source§

fn read(&self, path: &Path, limit: u64) -> Result<Contents>

Up to limit bytes of the regular file path, and its whole size. Anything but a regular file is refused without being opened: opening a FIFO or a device can block forever.
Source§

fn remove(&self, path: &Path) -> Result<()>

Removes the file path; a directory is refused.
Source§

fn rename(&self, from: &Path, to: &Path) -> Result<()>

Moves the file from to to, creating to’s directory and replacing a file there.
Source§

fn join(&self, base: &Path, path: &Path) -> PathBuf

path relative to base, as resolve joins them: base.join(path), so an absolute path stays as it is. A workspace whose paths can name another machine, such as Hosts, keeps such a path whole too.
Source§

fn watch( self: Arc<Self>, root: &Path, recursive: bool, listing: Listing, ) -> Result<Watch>

Watches root, a file or a directory (with recursive, every directory under it too), from now on: a batch of the paths created, changed or removed each time something changed, of the files files would list with listing. Dropping the Watch stops it. To miss nothing, list the files once after the watch has started. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

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