Skip to main content

Client

Struct Client 

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

Connection to incusd.

Implementations§

Source§

impl Client

Source

pub fn default_socket() -> PathBuf

Locate the socket the way the incus tools do: $INCUS_SOCKET, else $INCUS_DIR/unix.socket, else /var/lib/incus/unix.socket. On macOS the last fallback is the default isb machine’s forwarded socket, ~/.isb/machine/isb/incus.sock.

Source

pub fn new() -> Self

Client for the default socket and the default project.

Source

pub fn with_socket(socket: impl Into<PathBuf>) -> Self

Source

pub fn project(self, project: impl Into<String>) -> Self

Use an incus project other than default.

Source

pub fn timeouts(self, timeouts: Timeouts) -> Self

Source

pub fn socket(&self) -> &Path

Source

pub fn project_name(&self) -> &str

Source

pub fn get_timeouts(&self) -> &Timeouts

Source

pub fn server_info(&self) -> Result<Value>

GET /1.0: server info. Also a cheap reachability check.

Source

pub fn has_extension(&self, name: &str) -> Result<bool>

Whether the server lists the API extension name.

Source

pub fn server_version(&self) -> Result<Option<String>>

The server’s version (environment.server_version), if it says.

Source

pub fn oci_unsupported(&self) -> Option<String>

A sentence saying so when this incus cannot run OCI images (docker:, ghcr:, registry:), else None. Also None when incusd cannot be asked.

Source

pub fn wait_operation( &self, operation: &str, step: &str, deadline: Duration, ) -> Result<Value>

Wait for an operation to finish. Returns its metadata on success.

Source

pub fn start_operation( &self, method: &str, path: &str, body: Option<&Value>, ) -> Result<String>

Start an operation without waiting for it; returns its path (/1.0/operations/<id>). Low-level: most callers want the sandbox API.

Source

pub fn cancel_operation(&self, operation: &str) -> Result<()>

DELETE /1.0/operations/<id>. Fails for operations incus will not cancel.

Source

pub fn push_file( &self, instance: &str, path: &str, data: &[u8], uid: u32, gid: u32, mode: u32, ) -> Result<()>

Write a file into an instance (running or stopped), replacing it. Parent directories must exist; see Client::make_dir.

Source

pub fn make_dir( &self, instance: &str, path: &str, uid: u32, gid: u32, mode: u32, ) -> Result<()>

Create a directory in an instance; an existing one is left as is.

Source

pub fn console_log(&self, instance: &str) -> Result<Vec<u8>>

An instance’s console log as incus keeps it (an OCI app’s output).

Source

pub fn read_file(&self, instance: &str, path: &str) -> Result<Option<Vec<u8>>>

Read a file from an instance; None if it does not exist.

Source

pub fn events_websocket(&self, query: &str) -> Result<WebSocket<UnixStream>>

Follow /1.0/events?QUERY (all projects when the query says so) as a websocket. Reads time out every 5 s so a follower can check whether to stop; a timeout is not an error.

Trait Implementations§

Source§

impl Clone for Client

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 Client

Source§

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

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

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

Source§

fn vzip(self) -> V