pub struct FeagiZmqClientRequester { /* private fields */ }Expand description
A ZMQ DEALER client that sends requests and receives responses.
Uses DEALER socket (async REQ) to allow non-blocking request/response flow.
Uses reusable zmq::Message objects to minimize allocations.
§Example
ⓘ
let props = FeagiZmqClientRequesterProperties::new("tcp://localhost:5557")?;
let mut requester = props.as_boxed_client_requester();
requester.request_connect()?;
while requester.poll() != FeagiEndpointState::ActiveWaiting {
// wait for connection
}
requester.publish_request(b"Hello?")?;
loop {
match requester.poll() {
FeagiEndpointState::ActiveHasData => {
let response = requester.consume_retrieved_response()?;
process(response);
break;
}
FeagiEndpointState::ActiveWaiting => { /* still waiting */ }
_ => break,
}
}Trait Implementations§
Source§impl FeagiClient for FeagiZmqClientRequester
impl FeagiClient for FeagiZmqClientRequester
Source§fn poll(&mut self) -> &FeagiEndpointState
fn poll(&mut self) -> &FeagiEndpointState
Advances the internal state machine and returns the current state. Read more
Source§fn request_connect(&mut self) -> Result<(), FeagiNetworkError>
fn request_connect(&mut self) -> Result<(), FeagiNetworkError>
Initiates a connection to the configured server address. Read more
Source§fn request_disconnect(&mut self) -> Result<(), FeagiNetworkError>
fn request_disconnect(&mut self) -> Result<(), FeagiNetworkError>
Initiates disconnection from the server. Read more
Source§fn confirm_error_and_close(&mut self) -> Result<(), FeagiNetworkError>
fn confirm_error_and_close(&mut self) -> Result<(), FeagiNetworkError>
Acknowledges an error and closes the connection. Read more
fn get_endpoint_target(&self) -> TransportProtocolEndpoint
Source§impl FeagiClientRequester for FeagiZmqClientRequester
impl FeagiClientRequester for FeagiZmqClientRequester
Source§fn publish_request(&mut self, request: &[u8]) -> Result<(), FeagiNetworkError>
fn publish_request(&mut self, request: &[u8]) -> Result<(), FeagiNetworkError>
Sends a request to the server. Read more
Source§fn consume_retrieved_response(&mut self) -> Result<&[u8], FeagiNetworkError>
fn consume_retrieved_response(&mut self) -> Result<&[u8], FeagiNetworkError>
Consumes and returns the retrieved response data. Read more
Source§fn as_boxed_requester_properties(
&self,
) -> Box<dyn FeagiClientRequesterProperties>
fn as_boxed_requester_properties( &self, ) -> Box<dyn FeagiClientRequesterProperties>
Creates a boxed properties object for this requester. Read more
Auto Trait Implementations§
impl Freeze for FeagiZmqClientRequester
impl RefUnwindSafe for FeagiZmqClientRequester
impl Send for FeagiZmqClientRequester
impl !Sync for FeagiZmqClientRequester
impl Unpin for FeagiZmqClientRequester
impl UnsafeUnpin for FeagiZmqClientRequester
impl UnwindSafe for FeagiZmqClientRequester
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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