pub trait Host: Send + HostRequestOptions {
// Required methods
fn request<'life0, 'async_trait>(
&'life0 mut self,
c: Resource<Client>,
topic: Topic,
message: Resource<Message>,
options: Option<Resource<RequestOptions>>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<Resource<Message>>, Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn reply<'life0, 'async_trait>(
&'life0 mut self,
reply_to: Resource<Message>,
message: Resource<Message>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Required Methods§
sourcefn request<'life0, 'async_trait>(
&'life0 mut self,
c: Resource<Client>,
topic: Topic,
message: Resource<Message>,
options: Option<Resource<RequestOptions>>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<Resource<Message>>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn request<'life0, 'async_trait>(
&'life0 mut self,
c: Resource<Client>,
topic: Topic,
message: Resource<Message>,
options: Option<Resource<RequestOptions>>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<Resource<Message>>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Performs a blocking request/reply operation with an optional set of request options.
The behavior of this function is largely dependent on the options given to the function. If no options are provided, then the request/reply operation will block until a single message is received in response. If a timeout is provided, then the request/reply operation will block for the specified amount of time before returning an error if no messages were received (or the list of messages that were received). If both a timeout and an expected number of replies are provided, the function should return when either condition is met (whichever comes first)—e.g., (1) if no replies were received within the timeout return an error, (2) if the maximum expected number of replies were received before timeout, return the list of messages, or (3) if the timeout is reached before the expected number of replies, return the list of messages received up to that point.
sourcefn reply<'life0, 'async_trait>(
&'life0 mut self,
reply_to: Resource<Message>,
message: Resource<Message>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reply<'life0, 'async_trait>(
&'life0 mut self,
reply_to: Resource<Message>,
message: Resource<Message>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Replies to the given message with the given response message. The details of which topic the message is sent to is up to the implementation. This allows for reply-to details to be handled in the best way possible for the underlying messaging system.
Please note that this reply functionality is different than something like HTTP because there are several use cases in which a reply might not be required for every message (so this would be a noop). There are also cases when you might want to reply and then continue processing. Additionally, you might want to reply to a message several times (such as providing an update). So this function is allowed to be called multiple times, unlike something like HTTP where the reply is sent and the connection is closed.
Implementations on Foreign Types§
source§impl<_T: Host + ?Sized + Send> Host for &mut _T
impl<_T: Host + ?Sized + Send> Host for &mut _T
source§fn request<'life0, 'async_trait>(
&'life0 mut self,
c: Resource<Client>,
topic: Topic,
message: Resource<Message>,
options: Option<Resource<RequestOptions>>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<Resource<Message>>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn request<'life0, 'async_trait>(
&'life0 mut self,
c: Resource<Client>,
topic: Topic,
message: Resource<Message>,
options: Option<Resource<RequestOptions>>,
) -> Pin<Box<dyn Future<Output = Result<Result<Vec<Resource<Message>>, Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Performs a blocking request/reply operation with an optional set of request options.
The behavior of this function is largely dependent on the options given to the function. If no options are provided, then the request/reply operation will block until a single message is received in response. If a timeout is provided, then the request/reply operation will block for the specified amount of time before returning an error if no messages were received (or the list of messages that were received). If both a timeout and an expected number of replies are provided, the function should return when either condition is met (whichever comes first)—e.g., (1) if no replies were received within the timeout return an error, (2) if the maximum expected number of replies were received before timeout, return the list of messages, or (3) if the timeout is reached before the expected number of replies, return the list of messages received up to that point.
source§fn reply<'life0, 'async_trait>(
&'life0 mut self,
reply_to: Resource<Message>,
message: Resource<Message>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reply<'life0, 'async_trait>(
&'life0 mut self,
reply_to: Resource<Message>,
message: Resource<Message>,
) -> Pin<Box<dyn Future<Output = Result<Result<(), Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Replies to the given message with the given response message. The details of which topic the message is sent to is up to the implementation. This allows for reply-to details to be handled in the best way possible for the underlying messaging system.
Please note that this reply functionality is different than something like HTTP because there are several use cases in which a reply might not be required for every message (so this would be a noop). There are also cases when you might want to reply and then continue processing. Additionally, you might want to reply to a message several times (such as providing an update). So this function is allowed to be called multiple times, unlike something like HTTP where the reply is sent and the connection is closed.