pub struct Client { /* private fields */ }
Expand description
A handle to a client that allows communicating to a long-running process.
Implementations§
source§impl Client
impl Client
Protocol implementation
sourcepub fn handshake(
process: Child,
welcome_prefix: &str,
versions: &[usize],
desired_capabilities: &[&str],
) -> Result<Self, Error>
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.
sourcepub fn invoke(
&mut self,
command: &str,
meta: &mut dyn Iterator<Item = (&str, BString)>,
content: &mut dyn Read,
) -> Result<Status, Error>
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.
sourcepub 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>
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.
sourcepub fn as_read(&mut self) -> impl Read + '_
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.
sourcepub fn read_status(&mut self) -> Result<Status>
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
impl Client
Access
sourcepub fn capabilities(&self) -> &Capabilities
pub fn capabilities(&self) -> &Capabilities
Return the list of capabilities reported by the serving process.
sourcepub fn capabilities_mut(&mut self) -> &mut Capabilities
pub fn capabilities_mut(&mut self) -> &mut Capabilities
Return the mutable list of capabilities reported by the serving process.