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

A handle to a client that allows communicating to a long-running process.

Implementations§

source§

impl Client

Protocol implementation

source

pub fn handshake( process: Child, welcome_prefix: &str, versions: &[usize], desired_capabilities: &[&str] ) -> Result<Self, Error>

Given a spawned process as created from cmd, use the ‘long-running-process’ protocol to send welcome-prefix and supported versions, along with the desired_capabilities, and perform the handshake to negotiate a version to use along with obtaining supported capabilities, which may be a sub-set of the desired capabilities.

source

pub fn invoke( &mut self, command: &str, meta: &mut dyn Iterator<Item = (&str, BString)>, content: &mut dyn Read ) -> Result<Status, Error>

Invoke command and send all meta data before sending all content in full.

source

pub fn invoke_without_content<'a>( &mut self, command: &str, meta: &mut dyn Iterator<Item = (&'a str, BString)>, inspect_line: &mut dyn FnMut(&BStr) ) -> Result<Status, Error>

Invoke command while passing meta data, but don’t send any content, and return their status. Call inspect_line for each line that we see as command response.

This is for commands that don’t expect a content stream.

source

pub fn as_read(&mut self) -> impl Read + '_

Return a Read implementation that reads the server process output until the next flush package, and validates the status. If the status indicates failure, the last read will also fail.

source

pub fn read_status(&mut self) -> Result<Status>

Read a status= line from the process output until it is exhausted. Note that the last sent status line wins and no status line means that the Previous still counts.

source§

impl Client

Access

source

pub fn capabilities(&self) -> &Capabilities

Return the list of capabilities reported by the serving process.

source

pub fn capabilities_mut(&mut self) -> &mut Capabilities

Return the mutable list of capabilities reported by the serving process.

source

pub fn version(&self) -> usize

Return the negotiated version of the protocol.

Note that it is the highest one that both the client and the server support.

source§

impl Client

Lifecycle

source

pub fn into_child(self) -> Child

Return the child handle of the running process.

Note that this will naturally close input and output handles, which is a signal for the child process to shutdown.

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

§

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

§

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.