Skip to main content

Client

Struct Client 

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

A connection to a home’s runner service.

Implementations§

Source§

impl Client

Source

pub async fn record(&self, run: &RunName) -> Result<Option<RunRow>, ClientError>

Run run’s record; none for a run never recorded.

§Errors

The store couldn’t be read, or the connection ended.

Source

pub async fn forget(&self, run: &RunName) -> Result<(), ClientError>

Forgets run run’s record (what it created is left as it is).

§Errors

locked while an operation of the run is queued or running; the store couldn’t be written, or the connection ended.

Source

pub async fn expired(&self) -> Result<Vec<RunRow>, ClientError>

The recorded runs whose lifetime passed and that may still hold something: a reaper’s down each.

§Errors

The store couldn’t be read, or the connection ended.

Source

pub async fn console_command( &self, run: &RunName, target: Option<Target>, machine: &str, user: Option<&str>, ) -> Result<ShellCommand, ClientError>

The command that opens an interactive console into machine of run run (target: where to open it, else as recorded), as user when given, for this client to run in its own terminal.

§Errors

Where the run’s format has no way in; the connection ended.

Source

pub async fn native_console( &self, run: &RunName, target: Option<Target>, options: OpOptions, machine: &str, ) -> Result<NativeConsole, ClientError>

What opens running machine of run run in its hypervisor’s own app, its hypervisor asked with options’ values and secrets.

§Errors

no_console when the hypervisor has no app or the machine isn’t running; the connection ended.

Source

pub async fn graphical_console( &self, run: &RunName, target: Option<Target>, options: OpOptions, machine: &str, ) -> Result<HeldConsole, ClientError>

Running machine‘s graphical console, its hypervisor asked with options’ values and secrets, on a connection of its own that keeps its tunnel (when one carries it) open until the HeldConsole is dropped.

§Errors

no_console when the machine has none, or it doesn’t answer; server_auth_failed when a server refuses the credentials; the service doesn’t answer.

Source

pub async fn service_endpoints( &self, run: &RunName, target: Option<Target>, options: OpOptions, ) -> Result<Vec<ServiceEndpoint>, ClientError>

The service endpoints run run publishes, each where this computer reaches it: as the run gives it, or at a local forward through its jump host, which the service keeps open. One whose forward didn’t open says why.

§Errors

The run’s outputs can’t be read; the connection ended.

Source

pub async fn usage( &self, run: &RunName, target: Option<Target>, options: OpOptions, ) -> Result<Vec<MachineUsage>, ClientError>

What each running machine of run run uses now (CPU and memory), by name, as its engine samples it once; none for a format whose tool reports no per-machine figure.

§Errors

The run’s engine doesn’t answer, or its answer can’t be read; the connection ended.

Source

pub async fn downloads(&self) -> Result<Vec<Download>, ClientError>

What the runs’ own downloads fetched and the home records (images a pull pulled, boxes an up added), oldest first, each with its size when it can be read.

§Errors

The store couldn’t be read, or the connection ended.

Source

pub async fn remove_downloads( &self, which: DownloadsToRemove, ) -> Result<Vec<DownloadRemoval>, ClientError>

Removes the recorded downloads which names, each on its own (never forced): how each went, one its tool refused kept and said, the others removed.

§Errors

The store couldn’t be read or written, or the connection ended.

Source

pub async fn adopt_downloads( &self, adopted: Vec<DownloadToAdopt>, ) -> Result<Vec<Download>, ClientError>

Adopts adopted, downloads fetched outside the runs (by an earlier program’s own record), into the home’s record, each one on this computer now as it was fetched: they are listed and removed like the runs’ own. The downloads recorded for them, new or not.

§Errors

The engine or Vagrant couldn’t say what they hold (nothing was recorded), the store couldn’t be written, or the connection ended.

Source

pub async fn address_blocks_in_use( &self, except: Option<RunName>, docker_context: Option<String>, ) -> Result<Vec<String>, ClientError>

The IPv4 address blocks (CIDR) the networks of the engine Docker context docker_context reaches hold (the current one when none is named), but those of run except’s own networks: what a deployment’s networks must stay clear of.

§Errors

Docker is missing or the engine can’t say, or the connection ended.

Source

pub async fn public_key(&self) -> Result<String, ClientError>

The public half of the runner’s SSH key, one line (made when it has none).

§Errors

The key couldn’t be made (tool_missing without ssh-keygen) or read; the connection ended.

Source§

impl Client

Source

pub async fn connect( home: &Path, binary: Option<&Path>, ) -> Result<Client, ClientError>

Connects to home’s service, starting it (isothrum serve --home <home> --detach: binary when given, else the isothrum beside this program, else the one on PATH) when none answers, and waiting up to 30 seconds for it (less once it ended without answering).

§Errors

ClientError::Unavailable when none answers and none could be started (with the end of its log); ClientError::Protocol when the service speaks another protocol.

Source

pub async fn connect_exact( home: &Path, binary: Option<&Path>, ) -> Result<Client, ClientError>

Connects to home’s service of this release (VERSION), protocol and build (of binary: ServiceInfo::build): the one that runs when it is, else after replacing the one of another release or build (stopped, or ended when it doesn’t answer), else none; a service it then starts as Client::connect does (binary: the isothrum of this release). How it replaces a service is in the crate’s documentation.

§Errors

ClientError::Busy when the service of another release has operations queued or running: it is left running; ClientError::Version when the service started is another release (binary isn’t this one’s); ClientError::Unavailable when the service couldn’t be stopped (it doesn’t answer, and can’t be told from another process, or doesn’t end) or none could be started; ClientError::Protocol when it refused to stop.

Source

pub async fn connect_running(home: &Path) -> Result<Client, ClientError>

Connects to home’s service when one runs, starting none.

§Errors

ClientError::Unavailable when none answers.

Source

pub fn service(&self) -> &ServiceInfo

What the service said of itself when it started.

Source

pub async fn request(&self, command: Command) -> Result<Reply, ClientError>

Sends command, and returns its reply (an error reply as ClientError::Refused).

§Errors

The service refused it, or the connection ended: before command was sent (ClientError::Io), or after, unanswered (ClientError::Unanswered).

Source

pub async fn submit(&self, command: Command) -> Result<Accepted, ClientError>

Queues the operation command asks for.

§Errors

The service refused it (the run can’t be opened, another operation of the run is queued or running: ErrorCode::Locked, the service is stopping), or command isn’t an operation (ClientError::Protocol).

Source

pub async fn up( &self, target: Target, options: OpOptions, ) -> Result<Accepted, ClientError>

Queues up.

§Errors

As Client::submit.

Source

pub async fn down( &self, target: Target, options: OpOptions, ) -> Result<Accepted, ClientError>

Queues down.

§Errors

As Client::submit.

Source

pub async fn park( &self, target: Target, options: OpOptions, mode: Park, ) -> Result<Accepted, ClientError>

Queues park.

§Errors

As Client::submit.

Source

pub async fn resume( &self, target: Target, options: OpOptions, ) -> Result<Accepted, ClientError>

Queues resume.

§Errors

As Client::submit.

Source

pub async fn update( &self, target: Target, options: OpOptions, ) -> Result<Accepted, ClientError>

Queues update.

§Errors

As Client::submit.

Source

pub async fn retire( &self, target: Target, options: OpOptions, machine: String, ) -> Result<Accepted, ClientError>

Queues retire of machine.

§Errors

As Client::submit.

Source

pub async fn package( &self, target: Target, options: OpOptions, machine: String, output: PathBuf, ) -> Result<Accepted, ClientError>

Queues package of machine into the box file output.

§Errors

As Client::submit.

Source

pub async fn attach( &self, target: Target, options: OpOptions, machine: String, ) -> Result<Accepted, ClientError>

Queues attach of machine.

§Errors

As Client::submit.

Source

pub async fn exec( &self, target: Target, options: OpOptions, machine: String, argv: Vec<String>, ) -> Result<Accepted, ClientError>

Queues exec of argv in machine.

§Errors

As Client::submit.

Source

pub async fn cancel(&self, operation: OperationId) -> Result<(), ClientError>

Cancels operation: queued, it never begins; running, it is cut short.

§Errors

The service refused (an unknown or ended operation), or the connection ended.

Source

pub async fn status( &self, run: &RunName, target: Option<Target>, ) -> Result<Status, ClientError>

Run run’s status (target: where to open it, for a run not recorded yet; else as recorded).

§Errors

The runner couldn’t read it, or the connection ended.

Source

pub async fn status_with( &self, run: &RunName, target: Option<Target>, options: OpOptions, ) -> Result<Status, ClientError>

Client::status, the read’s tools given options’ values and secrets (a Proxmox VE module’s API token, for its VMs’ states on the server).

§Errors

As Client::status; server_auth_failed when a server refuses the credentials.

Source

pub async fn variables( &self, target: Target, ) -> Result<Vec<InputVariable>, ClientError>

The input variables the Terraform folder target names declares (name, type, default, sensitive), read from its files: a sensitive one is given as a secret, which no record keeps.

§Errors

The folder isn’t a Terraform module (unsupported, project_invalid), or the connection ended.

Source

pub async fn list(&self) -> Result<Vec<RunRow>, ClientError>

Every recorded run.

§Errors

The runner couldn’t read them, or the connection ended.

Source

pub async fn operations( &self, run: &RunName, limit: u32, ) -> Result<Vec<OperationRow>, ClientError>

Run run’s latest operations, newest first.

§Errors

The connection ended.

Source

pub async fn shutdown(&self) -> Result<(), ClientError>

Stops the service: its operations are cancelled and their tools stopped.

§Errors

The connection ended before the service answered.

Source

pub async fn subscribe( &self, run: Option<RunName>, after: Option<EventCursor>, ) -> Result<Subscription, ClientError>

The events after after (every one the service keeps when None), then the live ones, of run run or of every run, on a connection of their own.

§Errors

The service refused, or doesn’t answer.

Source

pub async fn follow(&self, command: Command) -> Result<Followed, ClientError>

Queues the operation command asks for and follows it: its events, from its queued to its ended. The subscription is open before the operation is queued, so none is missed.

§Errors

As Client::submit and Client::subscribe.

Source

pub async fn follow_again( &self, command: Command, ) -> Result<Followed, ClientError>

Follows command once more, its first sending unanswered (ClientError::Unanswered): the service may have queued it. When the run’s newest operation is of command’s kind and under way in this service (not ended, queued by this service’s process), that one is followed, from its queued: it is the first sending’s, or another client’s same operation, which command would only have queued behind. Else command is queued anew (Client::follow): a service that died with it took it along (one restarted since recovers it as an operation of its own, under way, which is then the one followed). One that already ended, and a target that doesn’t name its run, are queued anew too: an operation run twice brings the run to the same place.

§Errors

As Client::follow, and the run’s operations couldn’t be read.

Source

pub async fn wait(&self, operation: OperationId) -> Result<Event, ClientError>

Waits for operation operation’s last event: its result, or its error as ClientError::Operation (a cancel before it began, as one of code cancelled).

§Errors

The operation failed, or the connection ended.

Trait Implementations§

Source§

impl Debug for Client

Source§

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

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

impl Drop for Client

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Freeze for Client

§

impl Move for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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 = !

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