Skip to main content

HostMessage

Trait HostMessage 

Source
pub trait HostMessage: 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§

Source

fn new( &mut self, data: Vec<u8>, ) -> impl Future<Output = Result<Resource<Message>>> + Send

Source

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

Source

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

Source

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

Source

fn data( &mut self, self_: Resource<Message>, ) -> impl Future<Output = Result<Vec<u8>>> + Send

An opaque blob of data

Source

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

Source

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.).

Source

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

Source

fn set_metadata( &mut self, self_: Resource<Message>, meta: Metadata, ) -> impl Future<Output = Result<()>> + Send

Set the metadata

Source

fn remove_metadata( &mut self, self_: Resource<Message>, key: String, ) -> impl Future<Output = Result<()>> + Send

Remove a key-value pair from the metadata

Source

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".

Implementations on Foreign Types§

Source§

impl<_T: HostMessage + ?Sized + Send> HostMessage for &mut _T

Source§

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

Source§

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

Source§

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

Source§

fn data( &mut self, self_: Resource<Message>, ) -> impl Future<Output = Result<Vec<u8>>> + Send

An opaque blob of data

Source§

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

Source§

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.).

Source§

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

Source§

fn set_metadata( &mut self, self_: Resource<Message>, meta: Metadata, ) -> impl Future<Output = Result<()>> + Send

Set the metadata

Source§

fn remove_metadata( &mut self, self_: Resource<Message>, key: String, ) -> impl Future<Output = Result<()>> + Send

Remove a key-value pair from the metadata

Source§

fn new( &mut self, data: Vec<u8>, ) -> impl Future<Output = Result<Resource<Message>>> + Send

Source§

async fn drop(&mut self, rep: Resource<Message>) -> Result<()>

Implementors§

Source§

impl<H> HostMessage for Ctx<H>
where H: Handler,