Skip to main content

Message

Struct Message 

Source
pub struct Message<'a> { /* private fields */ }
Expand description

A message from the server, read in place from its frame: nothing is copied until the application asks for it.

payload decodes the payload into the application’s own type, borrowing from the frame where the type does.

Implementations§

Source§

impl<'a> Message<'a>

Source

pub fn kind(&self) -> &str

The message type (t).

Source

pub fn category(&self) -> Option<&str>

The category (c): "U" for updates, "S" for snapshots, "WSE" for the server’s own messages.

Source

pub fn topic(&self) -> Option<&str>

The topic a topic message was published to.

Source

pub fn position(&self) -> Option<Position>

The message’s position in its topic, when the server keeps the topic’s history.

Source

pub fn id(&self) -> Option<&str>

The message id (id).

Source

pub fn correlation_id(&self) -> Option<&str>

The correlation id (cid) pairing a reply with its request.

Source

pub fn timestamp(&self) -> Option<&str>

When the server sent it (ts, ISO 8601).

Source

pub fn priority(&self) -> Option<u8>

The priority (pri): 1 background, 3 low, 5 normal, 8 high, 10 critical.

Source

pub fn signature(&self) -> Option<&Signature>

For a message the server signed: the proof.

Source

pub fn payload<T: Deserialize<'a>>(&self) -> Result<T, Error>

The payload (p) decoded into T, from JSON or msgpack as the connection receives it. A message without a payload decodes as an empty map.

Source

pub fn payload_json(&self) -> Option<&'a str>

The payload’s JSON text, on a JSON connection.

Source

pub fn payload_value(&self) -> Result<Value, Error>

The payload as a JSON value, whatever the wire format.

Source

pub fn to_owned(&self) -> OwnedMessage

A copy the application can keep. The frame itself is shared, not copied, where it can be.

Trait Implementations§

Source§

impl<'a> Clone for Message<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Message<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Forget for Message<'a>

§

impl<'a> Freeze for Message<'a>

§

impl<'a> Move for Message<'a>

§

impl<'a> RefUnwindSafe for Message<'a>

§

impl<'a> Send for Message<'a>

§

impl<'a> Sync for Message<'a>

§

impl<'a> Unpin for Message<'a>

§

impl<'a> UnsafeUnpin for Message<'a>

§

impl<'a> UnwindSafe for Message<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more