pub trait HostMessage: Sized + Send {
// Required methods
fn new(
&mut self,
data: Vec<u8>,
) -> impl Future<Output = Result<Resource<Message>>> + Send;
fn topic(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Option<Topic>>> + Send;
fn content_type(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Option<String>>> + Send;
fn set_content_type(
&mut self,
self_: Resource<Message>,
content_type: String,
) -> impl Future<Output = Result<()>> + Send;
fn data(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Vec<u8>>> + Send;
fn set_data(
&mut self,
self_: Resource<Message>,
data: Vec<u8>,
) -> impl Future<Output = Result<()>> + Send;
fn metadata(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Option<Metadata>>> + Send;
fn add_metadata(
&mut self,
self_: Resource<Message>,
key: String,
value: String,
) -> impl Future<Output = Result<()>> + Send;
fn set_metadata(
&mut self,
self_: Resource<Message>,
meta: Metadata,
) -> impl Future<Output = Result<()>> + Send;
fn remove_metadata(
&mut self,
self_: Resource<Message>,
key: String,
) -> impl Future<Output = Result<()>> + Send;
fn drop(
&mut self,
rep: Resource<Message>,
) -> impl Future<Output = Result<()>> + Send;
}
Required Methods§
fn new( &mut self, data: Vec<u8>, ) -> impl Future<Output = Result<Resource<Message>>> + Send
Sourcefn topic(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Option<Topic>>> + Send
fn topic( &mut self, self_: Resource<Message>, ) -> impl Future<Output = Result<Option<Topic>>> + Send
The topic/subject/channel this message was received on, if any
Sourcefn content_type(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Option<String>>> + Send
fn content_type( &mut self, self_: Resource<Message>, ) -> impl Future<Output = Result<Option<String>>> + Send
An optional content-type describing the format of the data in the message. This is sometimes described as the “format” type
Sourcefn set_content_type(
&mut self,
self_: Resource<Message>,
content_type: String,
) -> impl Future<Output = Result<()>> + Send
fn set_content_type( &mut self, self_: Resource<Message>, content_type: String, ) -> impl Future<Output = Result<()>> + Send
Set the content-type describing the format of the data in the message. This is sometimes described as the “format” type
Sourcefn data(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Vec<u8>>> + Send
fn data( &mut self, self_: Resource<Message>, ) -> impl Future<Output = Result<Vec<u8>>> + Send
An opaque blob of data
Sourcefn set_data(
&mut self,
self_: Resource<Message>,
data: Vec<u8>,
) -> impl Future<Output = Result<()>> + Send
fn set_data( &mut self, self_: Resource<Message>, data: Vec<u8>, ) -> impl Future<Output = Result<()>> + Send
Set the opaque blob of data for this message, discarding the old value
Sourcefn metadata(
&mut self,
self_: Resource<Message>,
) -> impl Future<Output = Result<Option<Metadata>>> + Send
fn metadata( &mut self, self_: Resource<Message>, ) -> impl Future<Output = Result<Option<Metadata>>> + Send
Optional metadata (also called headers or attributes in some systems) attached to the message. This metadata is simply decoration and should not be interpreted by a host to ensure portability across different implementors (e.g., Kafka -> NATS, etc.).
Sourcefn add_metadata(
&mut self,
self_: Resource<Message>,
key: String,
value: String,
) -> impl Future<Output = Result<()>> + Send
fn add_metadata( &mut self, self_: Resource<Message>, key: String, value: String, ) -> impl Future<Output = Result<()>> + Send
Add a new key-value pair to the metadata, overwriting any existing value for the same key
Sourcefn set_metadata(
&mut self,
self_: Resource<Message>,
meta: Metadata,
) -> impl Future<Output = Result<()>> + Send
fn set_metadata( &mut self, self_: Resource<Message>, meta: Metadata, ) -> impl Future<Output = Result<()>> + Send
Set the metadata
Sourcefn remove_metadata(
&mut self,
self_: Resource<Message>,
key: String,
) -> impl Future<Output = Result<()>> + Send
fn remove_metadata( &mut self, self_: Resource<Message>, key: String, ) -> impl Future<Output = Result<()>> + Send
Remove a key-value pair from the metadata
fn drop( &mut self, rep: Resource<Message>, ) -> impl Future<Output = Result<()>> + 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.
Implementations on Foreign Types§
Source§impl<_T: HostMessage + ?Sized + Send> HostMessage for &mut _T
impl<_T: HostMessage + ?Sized + Send> HostMessage for &mut _T
Source§async fn topic(&mut self, self_: Resource<Message>) -> Result<Option<Topic>>
async fn topic(&mut self, self_: Resource<Message>) -> Result<Option<Topic>>
The topic/subject/channel this message was received on, if any
Source§async fn content_type(
&mut self,
self_: Resource<Message>,
) -> Result<Option<String>>
async fn content_type( &mut self, self_: Resource<Message>, ) -> Result<Option<String>>
An optional content-type describing the format of the data in the message. This is sometimes described as the “format” type
Source§async fn set_content_type(
&mut self,
self_: Resource<Message>,
content_type: String,
) -> Result<()>
async fn set_content_type( &mut self, self_: Resource<Message>, content_type: String, ) -> Result<()>
Set the content-type describing the format of the data in the message. This is sometimes described as the “format” type
Source§async fn set_data(
&mut self,
self_: Resource<Message>,
data: Vec<u8>,
) -> Result<()>
async fn set_data( &mut self, self_: Resource<Message>, data: Vec<u8>, ) -> Result<()>
Set the opaque blob of data for this message, discarding the old value
Source§async fn metadata(
&mut self,
self_: Resource<Message>,
) -> Result<Option<Metadata>>
async fn metadata( &mut self, self_: Resource<Message>, ) -> Result<Option<Metadata>>
Optional metadata (also called headers or attributes in some systems) attached to the message. This metadata is simply decoration and should not be interpreted by a host to ensure portability across different implementors (e.g., Kafka -> NATS, etc.).
Source§async fn add_metadata(
&mut self,
self_: Resource<Message>,
key: String,
value: String,
) -> Result<()>
async fn add_metadata( &mut self, self_: Resource<Message>, key: String, value: String, ) -> Result<()>
Add a new key-value pair to the metadata, overwriting any existing value for the same key
Source§async fn set_metadata(
&mut self,
self_: Resource<Message>,
meta: Metadata,
) -> Result<()>
async fn set_metadata( &mut self, self_: Resource<Message>, meta: Metadata, ) -> Result<()>
Set the metadata
Source§async fn remove_metadata(
&mut self,
self_: Resource<Message>,
key: String,
) -> Result<()>
async fn remove_metadata( &mut self, self_: Resource<Message>, key: String, ) -> Result<()>
Remove a key-value pair from the metadata