pub struct FrameClient { /* private fields */ }Expand description
Blocking request/response client for a backend daemon’s frame lane.
use running_process::broker::backend_sdk::FrameClient;
use running_process::broker::protocol::Endpoint;
let endpoint = Endpoint::unix_socket("my-daemon", "/tmp/my-daemon.sock")?;
let mut client = FrameClient::connect(&endpoint)?;
let response = client.request(0x7A63, b"ping".to_vec())?;
assert_eq!(response.payload, b"pong");Implementations§
Source§impl FrameClient
impl FrameClient
Sourcepub fn connect(endpoint: &Endpoint) -> Result<Self, FrameClientError>
pub fn connect(endpoint: &Endpoint) -> Result<Self, FrameClientError>
Connect to a backend endpoint using the platform local-socket name type (bare pipe name on Windows, filesystem path on Unix).
Sourcepub fn from_stream(stream: Stream) -> Self
pub fn from_stream(stream: Stream) -> Self
Wrap an already-connected local-socket stream (e.g. one opened
through a verified
BackendHandle).
Sourcepub fn request(
&mut self,
payload_protocol: u32,
payload: Vec<u8>,
) -> Result<Frame, FrameClientError>
pub fn request( &mut self, payload_protocol: u32, payload: Vec<u8>, ) -> Result<Frame, FrameClientError>
Send one request frame and block until its response arrives.
Assigns the next request id, sends
Frame::request(payload_protocol, payload), then reads frames
until one echoes the id. The returned frame is validated to be a
RESPONSE on the same payload protocol.
Sourcepub fn next_request_id(&self) -> u64
pub fn next_request_id(&self) -> u64
The request id the next Self::request call will use.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Bytes the internal frame reader has buffered but not yet consumed.
Zero on a client that has issued no Self::request. A consumer that
wants to take the raw socket back out via Self::into_stream checks
this first: nonzero means there is response data the bare socket would
not carry, so the take must be refused.
Sourcepub fn into_stream(self) -> Stream
pub fn into_stream(self) -> Stream
Consume the client and return the underlying local-socket stream.
Hands the negotiated socket back to a consumer that will speak its own
wire over it (see BrokerSession::into_backend_io). Any bytes still
buffered by the frame reader are dropped, so callers must verify
Self::buffered_len is zero before calling — which it always is on a
freshly adopted session that has issued no request.
Auto Trait Implementations§
impl Freeze for FrameClient
impl RefUnwindSafe for FrameClient
impl Send for FrameClient
impl Sync for FrameClient
impl Unpin for FrameClient
impl UnsafeUnpin for FrameClient
impl UnwindSafe for FrameClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more