pub struct EmbeddedClient { /* private fields */ }Expand description
A client that wraps a Kernel directly for in-process access.
§Example
ⓘ
use kaish_client::EmbeddedClient;
use kaish_kernel::{Kernel, KernelConfig};
let kernel = Kernel::new(KernelConfig::transient())?;
let client = EmbeddedClient::new(kernel);
let result = client.execute("X=42").await?;
assert!(result.ok());
let value = client.get_var("X").await?;
assert_eq!(value, Some(Value::Int(42)));Implementations§
Source§impl EmbeddedClient
impl EmbeddedClient
Sourcepub fn transient() -> ClientResult<Self>
pub fn transient() -> ClientResult<Self>
Create a new embedded client with a transient (non-persistent) kernel.
Sourcepub fn with_defaults() -> ClientResult<Self>
pub fn with_defaults() -> ClientResult<Self>
Create a new embedded client with default configuration.
Sourcepub async fn execute_streaming(
&self,
input: &str,
on_output: &mut dyn FnMut(&ExecResult),
) -> ClientResult<ExecResult>
pub async fn execute_streaming( &self, input: &str, on_output: &mut dyn FnMut(&ExecResult), ) -> ClientResult<ExecResult>
Execute with a per-statement output callback.
Each statement’s result is passed to on_output as it completes.
External commands in interactive mode already stream via Stdio::inherit();
this callback handles builtins and other captured output.
Trait Implementations§
Source§impl KernelClient for EmbeddedClient
impl KernelClient for EmbeddedClient
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<ExecResult>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<ExecResult>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute kaish source code. Read more
Source§fn get_var<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<Option<Value>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_var<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<Option<Value>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a variable value.
Source§fn set_var<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_var<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set a variable value.
Source§fn list_vars<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<Vec<(String, Value)>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_vars<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<Vec<(String, Value)>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List all variables.
Source§fn cwd<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cwd<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the current working directory.
Source§fn set_cwd<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_cwd<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set the current working directory.
Source§fn last_result<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<ExecResult>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn last_result<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<ExecResult>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the last execution result ($?).
Source§fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reset the kernel to initial state.
Source§fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Ping the kernel (health check).
Source§fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ClientResult<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Shutdown the kernel.
Source§fn read_blob<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<Vec<u8>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read_blob<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<Vec<u8>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a blob by ID. Read more
Source§fn write_blob<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
content_type: &'life1 str,
data: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = ClientResult<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write_blob<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
content_type: &'life1 str,
data: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = ClientResult<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Write a blob and return its ID. Read more
Source§fn delete_blob<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<bool>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_blob<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = ClientResult<bool>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a blob by ID. Read more
Auto Trait Implementations§
impl Freeze for EmbeddedClient
impl !RefUnwindSafe for EmbeddedClient
impl Send for EmbeddedClient
impl Sync for EmbeddedClient
impl Unpin for EmbeddedClient
impl UnsafeUnpin for EmbeddedClient
impl !UnwindSafe for EmbeddedClient
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
Mutably borrows from an owned value. Read more