Api

Struct Api 

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

Represents an implementation of DistantApi that works with the local machine where the server using this api is running. In other words, this is a direct impementation of the API instead of a proxy to another machine as seen with implementations on top of SSH and other protocol.

Implementations§

Source§

impl Api

Source

pub fn initialize(config: Config) -> Result<Self>

Initialize the api instance

Trait Implementations§

Source§

impl DistantApi for Api

Source§

fn read_file<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reads bytes from a file. Read more
Source§

fn read_file_text<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reads bytes from a file as text. Read more
Source§

fn write_file<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Writes bytes to a file, overwriting the file if it exists. Read more
Source§

fn write_file_text<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, data: String, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Writes text to a file, overwriting the file if it exists. Read more
Source§

fn append_file<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Writes bytes to the end of a file, creating it if it is missing. Read more
Source§

fn append_file_text<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, data: String, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Writes bytes to the end of a file, creating it if it is missing. Read more
Source§

fn read_dir<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, depth: usize, absolute: bool, canonicalize: bool, include_root: bool, ) -> Pin<Box<dyn Future<Output = Result<(Vec<DirEntry>, Vec<Error>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reads entries from a directory. Read more
Source§

fn create_dir<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, all: bool, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a directory. Read more
Source§

fn remove<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, force: bool, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes some file or directory. Read more
Source§

fn copy<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, src: PathBuf, dst: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Copies some file or directory. Read more
Source§

fn rename<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, src: PathBuf, dst: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Renames some file or directory. Read more
Source§

fn watch<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, recursive: bool, only: Vec<ChangeKind>, except: Vec<ChangeKind>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Watches a file or directory for changes. Read more
Source§

fn unwatch<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes a file or directory from being watched. Read more
Source§

fn exists<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if the specified path exists. Read more
Source§

fn metadata<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, path: PathBuf, canonicalize: bool, resolve_file_type: bool, ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reads metadata for a file or directory. Read more
Source§

fn set_permissions<'life0, 'async_trait>( &'life0 self, _ctx: DistantCtx, path: PathBuf, permissions: Permissions, options: SetPermissionsOptions, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets permissions for a file, directory, or symlink. Read more
Source§

fn search<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, query: SearchQuery, ) -> Pin<Box<dyn Future<Output = Result<SearchId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Searches files for matches based on a query. Read more
Cancels an actively-ongoing search. Read more
Source§

fn proc_spawn<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, cmd: String, environment: Environment, current_dir: Option<PathBuf>, pty: Option<PtySize>, ) -> Pin<Box<dyn Future<Output = Result<ProcessId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Spawns a new process, returning its id. Read more
Source§

fn proc_kill<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, id: ProcessId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Kills a running process by its id. Read more
Source§

fn proc_stdin<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, id: ProcessId, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends data to the stdin of the process with the specified id. Read more
Source§

fn proc_resize_pty<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, id: ProcessId, size: PtySize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Resizes the PTY of the process with the specified id. Read more
Source§

fn system_info<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, ) -> Pin<Box<dyn Future<Output = Result<SystemInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves information about the system. Read more
Source§

fn version<'life0, 'async_trait>( &'life0 self, ctx: DistantCtx, ) -> Pin<Box<dyn Future<Output = Result<Version>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves information about the server’s capabilities. Read more
Source§

fn on_connect<'life0, 'async_trait>( &'life0 self, id: u32, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Invoked whenever a new connection is established.
Source§

fn on_disconnect<'life0, 'async_trait>( &'life0 self, id: u32, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Invoked whenever an existing connection is dropped.

Auto Trait Implementations§

§

impl Freeze for Api

§

impl RefUnwindSafe for Api

§

impl Send for Api

§

impl Sync for Api

§

impl Unpin for Api

§

impl UnwindSafe for Api

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Consumes and produces Box<dyn Any>
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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V