pub trait MicroserviceClient:
Send
+ Sync
+ 'static {
// Required methods
fn send<Payload, Response>(
&self,
pattern: impl Into<String>,
payload: Payload,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send>>
where Payload: Serialize + Send + 'static,
Response: DeserializeOwned + Send + 'static;
fn emit<Payload>(
&self,
pattern: impl Into<String>,
payload: Payload,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>
where Payload: Serialize + Send + 'static;
}Expand description
MicroserviceClient Trait
Defines the interface for sending messages and emitting events to microservices. Implement this trait to create custom transport adapters (e.g., TCP, Redis, NATS).
§Methods
send: Sends a request-response style message and waits for a responseemit: Sends an event (fire-and-forget) without waiting for a response
§Type Parameters
Payload: The message payload type (must be serializable)Response: The response type (must be deserializable)
Required Methods§
Sourcefn send<Payload, Response>(
&self,
pattern: impl Into<String>,
payload: Payload,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send>>
fn send<Payload, Response>( &self, pattern: impl Into<String>, payload: Payload, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.