Skip to main content

Client

Struct Client 

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

A connection to the daemon.

Implementations§

Source§

impl Client

Source

pub fn connect(path: &Path) -> Result<Self>

Connects to the daemon socket at path.

§Errors

Connection errors.

Source

pub fn connect_with_timeout(path: &Path, timeout: Duration) -> Result<Self>

Connects to the daemon socket at path, with timeout for the connect and each read and write instead of TIMEOUT.

§Errors

Connection errors, or a zero timeout.

Source

pub fn hello(&mut self, solver_path: &str) -> Result<Identity>

The identity of the solver at solver_path.

§Errors

I/O errors, or the daemon’s error message.

Source

pub fn hello_in_mode( &mut self, solver_path: &str, mode: VerificationMode, ) -> Result<Identity>

Identifies a solver and negotiates the connection’s cache namespace.

Call once before any cache lookup or store. A failed or repeated handshake retires the connection; connect again to retry.

§Errors

I/O errors, a rejected handshake, or a stale daemon protocol.

Source

pub fn get(&mut self, key: &[u8; 32]) -> Result<Option<Vec<u8>>>

The cached reply for key, or None on a miss. Requires a successful Self::hello or Self::hello_in_mode.

§Errors

I/O errors.

Source

pub fn get_with_effort( &mut self, key: &[u8; 32], ) -> Result<Option<(Vec<u8>, Option<Effort>)>>

The cached reply for key with its recorded effort, if the daemon sent one, or None on a miss.

§Errors

I/O errors.

Source

pub fn put( &mut self, key: &[u8; 32], meta: PutMeta, reply: Vec<u8>, ) -> Result<()>

Stores reply for key. Requires a successful Self::hello or Self::hello_in_mode.

§Errors

I/O errors.

Source

pub fn put_all( &mut self, puts: impl IntoIterator<Item = ([u8; 32], PutMeta, Vec<u8>)>, ) -> Result<()>

Stores every (key, meta, reply) in order, sending up to a window of requests before reading their acknowledgements, so a session’s stores cost a few round trips instead of one each. The daemon answers each request in order, exactly as for Client::put.

§Errors

I/O errors. Stores before the failing window may have been made.

Source

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

The daemon’s counters since it started.

§Errors

I/O errors and malformed replies.

Source

pub fn info(&mut self) -> Result<Info>

The daemon’s configuration and state.

§Errors

I/O errors and malformed replies. A daemon that predates INFO closes the connection, which is an I/O error.

Trait Implementations§

Source§

impl Debug for Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Client

§

impl Freeze for Client

§

impl Move 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.