Trait HostMessage

Source
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§

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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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

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

Set the content-type describing the format of the data in the message. This is sometimes described as the “format” type

Source§

async fn data(&mut self, self_: Resource<Message>) -> Result<Vec<u8>>

An opaque blob of data

Source§

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

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

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

Set the metadata

Source§

async fn remove_metadata( &mut self, self_: Resource<Message>, key: String, ) -> Result<()>

Remove a key-value pair from the metadata

Source§

async fn new(&mut self, data: Vec<u8>) -> Result<Resource<Message>>

Source§

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

Implementors§