Trait splinter::service::ServiceNetworkSender
source · [−]pub trait ServiceNetworkSender: Send {
fn send(
&self,
recipient: &str,
message: &[u8]
) -> Result<(), ServiceSendError>;
fn send_and_await(
&self,
recipient: &str,
message: &[u8]
) -> Result<Vec<u8>, ServiceSendError>;
fn reply(
&self,
message_origin: &ServiceMessageContext,
message: &[u8]
) -> Result<(), ServiceSendError>;
fn clone_box(&self) -> Box<dyn ServiceNetworkSender>;
fn send_with_sender(
&mut self,
recipient: &str,
message: &[u8],
sender: &str
) -> Result<(), ServiceSendError>;
}
Expand description
The ServiceNetworkSender trait allows a service to send its own messages, such as replies to the original message or forwarding the message to other services on the same circuit. It does not expose the circuit information directly.
Required Methods
Send the message bytes to the given recipient (another service)
fn send_and_await(
&self,
recipient: &str,
message: &[u8]
) -> Result<Vec<u8>, ServiceSendError>
fn send_and_await(
&self,
recipient: &str,
message: &[u8]
) -> Result<Vec<u8>, ServiceSendError>
Send the message bytes to the given recipient (another service) and await the reply. This function blocks until the reply is returned.
fn reply(
&self,
message_origin: &ServiceMessageContext,
message: &[u8]
) -> Result<(), ServiceSendError>
fn reply(
&self,
message_origin: &ServiceMessageContext,
message: &[u8]
) -> Result<(), ServiceSendError>
Send the message bytes back to the origin specified in the given message context.
fn clone_box(&self) -> Box<dyn ServiceNetworkSender>
fn clone_box(&self) -> Box<dyn ServiceNetworkSender>
Clone this instance into Boxed, dynamic trait
fn send_with_sender(
&mut self,
recipient: &str,
message: &[u8],
sender: &str
) -> Result<(), ServiceSendError>
fn send_with_sender(
&mut self,
recipient: &str,
message: &[u8],
sender: &str
) -> Result<(), ServiceSendError>
Send the message bytes to the given recipient (another service) with a configurable message sender