pub struct Message {
pub topic: OwnedBytes,
pub payload: OwnedBytes,
}
Expand description
A PubSub
message.
Fields§
§topic: OwnedBytes
The topic of the message.
payload: OwnedBytes
The payload of the message.
Implementations§
§impl Message
impl Message
pub fn new<Topic, Payload>(
topic: &Topic,
payload: &Payload
) -> Result<Message, Error>where
Topic: Serialize,
Payload: Serialize,
pub fn new<Topic, Payload>( topic: &Topic, payload: &Payload ) -> Result<Message, Error>where Topic: Serialize, Payload: Serialize,
pub fn raw<S, B>(topic: S, payload: B) -> Messagewhere
S: Into<OwnedBytes>,
B: Into<OwnedBytes>,
pub fn raw<S, B>(topic: S, payload: B) -> Messagewhere S: Into<OwnedBytes>, B: Into<OwnedBytes>,
Creates a new message with a raw payload.
pub fn topic<'a, Topic>(&'a self) -> Result<Topic, Error>where
Topic: Deserialize<'a>,
pub fn topic<'a, Topic>(&'a self) -> Result<Topic, Error>where Topic: Deserialize<'a>,
Deserialize the topic as Topic
using pot
.
Errors
Returns an error if topic
fails to deserialize with pot
.
pub fn payload<'a, Payload>(&'a self) -> Result<Payload, Error>where
Payload: Deserialize<'a>,
pub fn payload<'a, Payload>(&'a self) -> Result<Payload, Error>where Payload: Deserialize<'a>,
Deserialize the payload as Payload
using pot
.
Errors
Returns an error if payload
fails to deserialize with pot
.
Trait Implementations§
§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Message, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for Message
impl Serialize for Message
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more