Publishable

Trait Publishable 

Source
pub trait Publishable {
    type Error: Into<Error>;

    // Required methods
    fn topic(&self, device: &Device) -> impl Into<String> + Send;
    fn payload(&self) -> Result<impl Into<Bytes> + Send, Self::Error>;
    fn publish_overrides(&self) -> PublishOptions;
}
Expand description

Types which may be published by a publisher to a MQTT broker.

Required Associated Types§

Source

type Error: Into<Error>

This trait’s error type.

Must be convertible into this library’s own error type.

Required Methods§

Source

fn topic(&self, device: &Device) -> impl Into<String> + Send

Return the MQTT topic.

Source

fn payload(&self) -> Result<impl Into<Bytes> + Send, Self::Error>

Return the payload to publish.

§Errors

May return an error if there is a failure while encoding the payload.

Source

fn publish_overrides(&self) -> PublishOptions

Return the PublishOptions overrides for this Publishable.

These overrides are part of an override mechanism to set the options for the Publisher trait implementor. These PublishOptions may be overriden by the caller of crate::Publisher::publish_with(), and they have precedence over the fallback options.

Note: Only the option fields explicitly overriden should be written, letting all other fields to None.

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.

Implementors§