Skip to main content

CCCCClient

Struct CCCCClient 

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

Blocking CCCC Daemon IPC v1 client.

Implementations§

Source§

impl CCCCClient

Source

pub fn discover() -> Result<Self>

Discover the currently running daemon.

Examples found in repository?
examples/compat_check.rs (line 4)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let client = CCCCClient::discover()?;
5    let requirements = CompatibilityRequirements {
6        minimum_ipc_version: 1,
7        operations: vec![
8            "groups",
9            "group_show",
10            "send",
11            "reply",
12            "inbox_list",
13            "context_get",
14            "context_sync",
15            "group_preamble_get",
16            "terminal_history",
17        ],
18        ..Default::default()
19    };
20    let daemon = client.assert_compatible(&requirements)?;
21    println!(
22        "CCCC {} ({}) is compatible with IPC v{}",
23        daemon.version,
24        daemon.implementation.as_deref().unwrap_or("unknown"),
25        daemon.ipc_v
26    );
27    Ok(())
28}
Source

pub fn discover_in(cccc_home: Option<&Path>) -> Result<Self>

Discover a daemon under an explicit CCCC_HOME.

Source

pub fn new(endpoint: DaemonEndpoint) -> Self

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Source

pub fn endpoint(&self) -> &DaemonEndpoint

Source

pub fn call( &self, op: &str, args: Map<String, Value>, ) -> Result<Map<String, Value>>

Call any non-streaming daemon operation and return its result object.

Source

pub fn call_raw( &self, op: &str, args: Map<String, Value>, ) -> Result<DaemonResponse>

Call an operation and retain the full response envelope.

Source

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

Source

pub fn groups(&self) -> Result<Map<String, Value>>

Source

pub fn group_show(&self, group_id: &str) -> Result<Map<String, Value>>

Source

pub fn send( &self, group_id: &str, text: &str, by: &str, ) -> Result<Map<String, Value>>

Source

pub fn reply( &self, group_id: &str, reply_to: &str, text: &str, by: &str, ) -> Result<Map<String, Value>>

Source

pub fn inbox_list( &self, group_id: &str, actor_id: &str, limit: Option<u32>, ) -> Result<Map<String, Value>>

Source

pub fn context_get(&self, group_id: &str) -> Result<Map<String, Value>>

Source

pub fn context_sync( &self, group_id: &str, by: &str, operations: Vec<Value>, ) -> Result<Map<String, Value>>

Source

pub fn assert_compatible( &self, requirements: &CompatibilityRequirements<'_>, ) -> Result<PingResult>

Validate protocol, advertised capabilities, and actual op recognition.

Examples found in repository?
examples/compat_check.rs (line 20)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let client = CCCCClient::discover()?;
5    let requirements = CompatibilityRequirements {
6        minimum_ipc_version: 1,
7        operations: vec![
8            "groups",
9            "group_show",
10            "send",
11            "reply",
12            "inbox_list",
13            "context_get",
14            "context_sync",
15            "group_preamble_get",
16            "terminal_history",
17        ],
18        ..Default::default()
19    };
20    let daemon = client.assert_compatible(&requirements)?;
21    println!(
22        "CCCC {} ({}) is compatible with IPC v{}",
23        daemon.version,
24        daemon.implementation.as_deref().unwrap_or("unknown"),
25        daemon.ipc_v
26    );
27    Ok(())
28}

Trait Implementations§

Source§

impl Clone for CCCCClient

Source§

fn clone(&self) -> CCCCClient

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 CCCCClient

Source§

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

Formats the value using the given formatter. 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<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, 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> 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.