Skip to main content

Hosts

Struct Hosts 

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

A workspace (the inner one, such as Local) whose paths written HOST:PATH, HOST the name of one of its Remotes, are that host’s PATH, as scp reads them: bench:~/strata/src/lib.rs, bench:/srv/app. Every other path is the inner workspace’s. Every path it gives back for a remote file (canonical, files) keeps the HOST: form, so the facts and footprints the tools make of them can be passed back as they are; a relative path joined onto a HOST: base stays there.

Its host is the inner workspace’s, as its project is there; a call on a HOST: path waits for the transport.

Implementations§

Source§

impl Hosts

Source

pub fn new( inner: Arc<dyn Workspace>, remotes: impl IntoIterator<Item = Remote>, ) -> Self

inner, and remotes by their names; a later remote replaces an earlier one of the same name.

Source

pub fn route(&self, path: &Path) -> Option<(&Remote, PathBuf)>

The remote path names and the path there: ~ for HOST: alone.

Trait Implementations§

Source§

impl Clone for Hosts

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 Hosts

Source§

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

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

impl Workspace for Hosts

Source§

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

All in one go on their host when every path is on one, else one by one.

Source§

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

Within one host, or within the inner workspace; a move between them is refused.

Source§

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

On the host dir names, else in the inner workspace.

Source§

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

A remote root is looked at every second, as the default does.

Source§

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

Where it is when it is not this machine, such as ssh://dev@box; None for this machine.
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 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 excerpt(&self, path: &Path, first: usize, count: usize) -> Result<Excerpt>

Lines first (from 1) on, at most count of them, of the regular text file path, with how many lines it has and the hash of all of it. Refused, as read_text refuses, when it is no regular file, larger than MAX_FILE_BYTES (a FileTooLarge error) or not UTF-8 (an InvalidData error); a workspace that sends only the lines asked of a file larger than MAX_BYTES, such as a remote one, checks only those for UTF-8. Read more
Source§

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

Replaces the file path with bytes in one step, creating its directory, keeping its permissions, and refusing a read-only file or anything but a regular file (see write_atomic).
Source§

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

writes bytes to path and says what the file held before, as read with limit reads it: a NotFound error when there was no file, the file’s own when it could not be read. What a tool that writes a file diffs against; a workspace where each call costs a round trip, such as a remote one, does both in one. Read more
Source§

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

writes bytes to the regular file path only while it holds the text whose content_hash is held: None when it did. Otherwise nothing is written and it says what the file holds instead, as read with a limit of MAX_FILE_BYTES reads it. What an edit made from text seen before writes with; a workspace where each call costs a round trip, such as a remote one, checks and writes in one. Read more
Source§

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

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

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

path made absolute, with the links of its longest existing part followed (the file’s own too, when it exists) and .. folded, so two spellings of one file come out alike. A footprint is made with it, which may be on a thread that must not wait: a remote workspace may answer from a cache, or fold .. only.
Source§

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

The regular files under root (or root itself when it is a file), in walk order, as root joined with their path below it: those listing keeps (Listing), and only those matching glob, such as *.rs, when it is given. A malformed glob is an InvalidInput error that says so.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Hosts

§

impl !UnwindSafe for Hosts

§

impl Freeze for Hosts

§

impl Send for Hosts

§

impl Sync for Hosts

§

impl Unpin for Hosts

§

impl UnsafeUnpin for Hosts

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