pub struct Client { /* private fields */ }Expand description
A connection to the Sessions service. Cloning is cheap and shares the connection.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(o: Options) -> Result<Client>
pub async fn new(o: Options) -> Result<Client>
Connects to the sandbox plane (lazily: the connection is made on the first call).
Sourcepub fn from_channel(
channel: Channel,
ts: SharedTokenSource,
instance: impl Into<String>,
) -> Client
pub fn from_channel( channel: Channel, ts: SharedTokenSource, instance: impl Into<String>, ) -> Client
Builds a client on an existing channel. instance may be empty if only full resource
names are used.
Sourcepub fn raw(&self) -> SessionsClient<Channel>
pub fn raw(&self) -> SessionsClient<Channel>
The generated gRPC client, for calls this crate doesn’t wrap. It covers only the SDK’s
subset of the Sessions API. Authorize each request with Client::request.
Sourcepub fn instance(&self) -> String
pub fn instance(&self) -> String
The resource name “instances/{id}” used as the parent of sessions.
Sourcepub fn token_source(&self) -> SharedTokenSource
pub fn token_source(&self) -> SharedTokenSource
The token source the client authorizes calls with.
Source§impl Client
impl Client
Sourcepub async fn exec(
&self,
name: &str,
argv: &[String],
o: ExecOptions<'_>,
) -> Result<ExecResult>
pub async fn exec( &self, name: &str, argv: &[String], o: ExecOptions<'_>, ) -> Result<ExecResult>
Runs argv in the session (no shell; use Client::shell for that). A parked session is
resumed by the plane first. Exec is refused while a shell attach holds the guest (see
is_guest_held). A non-zero exit is reported in ExecResult, not as an error. If the
connection fails once the command may have started, the error is
Error::OutcomeUnknown with the transport error as its cause.
Sourcepub async fn output(
&self,
name: &str,
argv: &[String],
o: ExecOptions<'_>,
) -> Result<Vec<u8>>
pub async fn output( &self, name: &str, argv: &[String], o: ExecOptions<'_>, ) -> Result<Vec<u8>>
Runs argv and returns its stdout, or Error::Exit on a non-zero exit or a timeout.
Source§impl Client
impl Client
Sourcepub async fn write_file(
&self,
name: &str,
path: &str,
data: Vec<u8>,
mode: u32,
) -> Result<()>
pub async fn write_file( &self, name: &str, path: &str, data: Vec<u8>, mode: u32, ) -> Result<()>
Atomically replaces path (creating parent directories) with data, with permission bits
mode. It refuses an empty path and an existing directory (exit code 21, as an
Error::Exit).
Source§impl Client
impl Client
Sourcepub async fn complete_first_attach(&self, name: &str) -> Result<()>
pub async fn complete_first_attach(&self, name: &str) -> Result<()>
Completes a new workspace session’s first attach, which the plane requires before it allows Exec (until then Exec fails with FailedPrecondition “attach with a shell first to upload the workspace”).
It opens one AttachSession stream with a shell, and if the plane reports
workspace_pending, uploads an empty tree: a single FULL_TAR chunk holding an empty tar
archive (gzip’d when the plane offers GZIP). It waits for WorkspaceReady and then detaches
by canceling the stream. A session that isn’t pending is left as it is. It gives up after
FIRST_ATTACH_TIMEOUT (an Error::Timeout with op “start”).
Source§impl Client
impl Client
Sourcepub async fn create(&self, s: Session) -> Result<Session>
pub async fn create(&self, s: Session) -> Result<Session>
Creates a session in the client’s instance.
Sourcepub async fn get(&self, name: &str) -> Result<Session>
pub async fn get(&self, name: &str) -> Result<Session>
Fetches a session by full resource name.
Sourcepub async fn list(&self, o: &ListOptions) -> Result<Vec<Session>>
pub async fn list(&self, o: &ListOptions) -> Result<Vec<Session>>
Every session in the instance, following page tokens.
Sourcepub async fn resolve(&self, reference: &str) -> Result<Session>
pub async fn resolve(&self, reference: &str) -> Result<Session>
Finds a session the way chainctl’s SESSION argument does: a full resource name, a short ID,
or a display name (“quiet-harbor”, “app/quiet-harbor”, “acme/app/quiet-harbor”). No match
is Error::NotFound (what “session”); several are Error::Ambiguous.
Sourcepub async fn delete(&self, name: &str) -> Result<()>
pub async fn delete(&self, name: &str) -> Result<()>
Tears down the guest and discards its snapshot (or removes a reaped tombstone).
Sourcepub async fn update(&self, s: Session, paths: &[&str]) -> Result<Session>
pub async fn update(&self, s: Session, paths: &[&str]) -> Result<Session>
Applies a field-masked update, e.g. paths “display_name”.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].