Skip to main content

ClawCoreClient

Struct ClawCoreClient 

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

Async client for the claw_core daemon.

Communicates over a Unix socket using line-delimited JSON (one request per line, one response per line).

§Example

use claw_core_protocol::{ClawCoreClient, CreateSessionParams, ExecRunParams};

let mut client = ClawCoreClient::connect("/tmp/trl.sock").await?;

let session = client.create_session(CreateSessionParams::default()).await?;
let result = client.exec_run(ExecRunParams {
    session_id: session.session_id.clone(),
    command: "echo hello".into(),
    timeout_s: Some(30),
    stdin: None,
    env: None,
}).await?;

println!("stdout: {}", result.stdout);

Implementations§

Source§

impl ClawCoreClient

Source

pub async fn connect(socket_path: &str) -> Result<Self>

Connect to the claw_core daemon at the given Unix socket path.

Source

pub async fn send_request( &mut self, method: &str, params: Value, ) -> Result<RpcResponse>

Send a raw RPC request and return the parsed response.

Source

pub async fn ping(&mut self) -> Result<PingResult>

system.ping — health check.

Source

pub async fn stats(&mut self) -> Result<SystemStats>

system.stats — runtime statistics.

Source

pub async fn create_session( &mut self, params: CreateSessionParams, ) -> Result<CreateSessionResult>

session.create — create a new terminal session.

Source

pub async fn list_sessions(&mut self) -> Result<SessionListResult>

session.list — list active sessions.

Source

pub async fn session_info(&mut self, session_id: &str) -> Result<SessionInfo>

session.info — get details about a session.

Source

pub async fn destroy_session( &mut self, params: DestroySessionParams, ) -> Result<DestroySessionResult>

session.destroy — terminate and clean up a session.

Source

pub async fn exec_run(&mut self, params: ExecRunParams) -> Result<ExecRunResult>

exec.run — execute a command in a session (buffered, waits for completion).

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<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, 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.