Skip to main content

Client

Struct Client 

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

A configured Sail client. Cheap to clone; shares transport across clones.

Implementations§

Source§

impl Client

Source

pub fn builder(api_key: impl Into<String>) -> ClientBuilder

Start a ClientBuilder.

Source

pub fn from_env() -> Result<Client, SailError>

Build a client from the environment (SAIL_MODE, SAIL_API_KEY, …).

Source

pub fn from_config(config: Config) -> Result<Client, SailError>

Build a client from an already-resolved Config.

Source

pub fn config(&self) -> &Config

The resolved configuration.

Source

pub async fn create_sailbox( &self, req: &CreateSailboxRequest, ) -> Result<SailboxHandle, SailError>

Create a sailbox.

Source

pub async fn get_sailbox( &self, sailbox_id: &str, ) -> Result<SailboxInfo, SailError>

Fetch a single sailbox.

Source

pub async fn list_sailboxes( &self, query: &ListQuery, ) -> Result<SailboxPage, SailError>

List sailboxes in the current org.

Source

pub async fn terminate_sailbox(&self, sailbox_id: &str) -> Result<(), SailError>

Terminate a sailbox (idempotent).

Source

pub async fn pause_sailbox(&self, sailbox_id: &str) -> Result<(), SailError>

Pause a sailbox.

Source

pub async fn sleep_sailbox(&self, sailbox_id: &str) -> Result<(), SailError>

Sleep a sailbox.

Source

pub async fn resume_sailbox( &self, sailbox_id: &str, ) -> Result<SailboxHandle, SailError>

Resume a paused/sleeping sailbox.

Source

pub async fn checkpoint_sailbox( &self, sailbox_id: &str, ) -> Result<SailboxCheckpoint, SailError>

Checkpoint a running sailbox.

Source

pub async fn create_from_checkpoint( &self, checkpoint_id: &str, name: Option<&str>, timeout_seconds: Option<i64>, ) -> Result<SailboxHandle, SailError>

Create a new sailbox from a checkpoint.

Source

pub async fn upgrade_sailbox( &self, sailbox_id: &str, ) -> Result<UpgradeOutcome, SailError>

Upgrade the in-guest agent (applies now if running, else at next wake).

Source

pub async fn expose_listener( &self, sailbox_id: &str, guest_port: u32, protocol: &str, allowlist: &[String], ) -> Result<Value, SailError>

Expose a guest port at runtime; returns the add-listener response.

Source

pub async fn unexpose_listener( &self, sailbox_id: &str, guest_port: u32, ) -> Result<(), SailError>

Remove a runtime ingress port.

Source

pub async fn list_listeners( &self, sailbox_id: &str, ) -> Result<Vec<Listener>, SailError>

List a sailbox’s ingress listeners without resuming (waking) the box.

Source

pub async fn get_listener( &self, sailbox_id: &str, guest_port: u32, ) -> Result<Listener, SailError>

Fetch one ingress listener by guest port without resuming (waking) the box; a missing port is a SailError::NotFound.

Source

pub async fn ingress_auth_headers( &self, sailbox_id: &str, ) -> Result<Vec<(String, String)>, SailError>

Ingress-identity headers for this sailbox.

Source

pub async fn get_volume( &self, name: &str, mint_if_missing: bool, ) -> Result<NfsVolume, SailError>

Look up (optionally minting) an NFS volume by name.

Source

pub async fn list_volumes( &self, max_objects: Option<i64>, ) -> Result<Vec<NfsVolume>, SailError>

List NFS volumes in the current org.

Source

pub async fn delete_volume( &self, volume_id: &str, allow_missing: bool, ) -> Result<Option<NfsVolume>, SailError>

Delete a volume by id.

Source

pub async fn find_app( &self, name: &str, mint_if_missing: bool, ) -> Result<App, SailError>

Find an app by name on the central API, optionally minting it.

Source

pub async fn list_apps(&self) -> Result<Vec<AppOverview>, SailError>

List apps in the current org with rollup usage.

Source

pub async fn exec( &self, sailbox_id: &str, argv: Vec<String>, options: ExecOptions, ) -> Result<ExecProcess, SailError>

Run a command in a sailbox and return a handle to the live process.

Resumes (wakes) the sailbox to reach it. The returned ExecProcess streams output, accepts stdin, and resolves the exit status; dropping it detaches without killing the command.

§Runtime

Spawns the output pump on the calling task’s tokio runtime (see ExecProcess::start).

Source

pub async fn download_file( &self, sailbox_id: &str, remote_path: &str, ) -> Result<FileReader, SailError>

Open a streaming read of a guest file. Resumes (wakes) the sailbox to reach it; the returned FileReader yields chunks until end of file.

§Runtime

Spawns the read pump on the calling task’s tokio runtime (see [crate::worker::WorkerProxy::read_file]).

Source

pub async fn upload_file( &self, sailbox_id: &str, remote_path: &str, options: UploadOptions, ) -> Result<FileWriter, SailError>

Open a streaming write to a guest file. Resumes (wakes) the sailbox to reach it; feed the returned FileWriter with write_chunk and end with finish, so a large source is never buffered whole.

§Runtime

Spawns the write RPC on the calling task’s tokio runtime (see [crate::worker::WorkerProxy::write_file]).

Source§

impl Client

Source

pub async fn enable_ssh( &self, sailbox_id: &str, public_key: &str, wait: bool, timeout: Duration, ) -> Result<Option<SshEndpoint>, SailError>

Make a running sailbox reachable over SSH, returning the endpoint when wait is set (else None). Resumes (wakes) the sailbox to reach it, reserves guest port 22 as TCP ingress if not already exposed, installs public_key, and (re)starts sshd. Idempotent and safe to re-run.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = 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

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