pub struct Remote { /* private fields */ }Expand description
Implementations§
Source§impl Remote
impl Remote
Sourcepub fn new(
name: impl Into<String>,
transport: impl IntoIterator<Item = impl Into<OsString>>,
launcher: Launcher,
) -> Result<Self>
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.
Trait Implementations§
Source§impl Workspace for Remote
impl Workspace for Remote
Source§fn excerpt(&self, path: &Path, first: usize, count: usize) -> Result<Excerpt>
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>>>
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<()>
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>>
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>>
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
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>>
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>
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>
fn stat(&self, path: &Path) -> Result<Stat>
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>
fn read(&self, path: &Path, limit: u64) -> Result<Contents>
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 rename(&self, from: &Path, to: &Path) -> Result<()>
fn rename(&self, from: &Path, to: &Path) -> Result<()>
from to to, creating to’s directory and
replacing a file there.Source§fn join(&self, base: &Path, path: &Path) -> PathBuf
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>
fn watch( self: Arc<Self>, root: &Path, recursive: bool, listing: Listing, ) -> Result<Watch>
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