pub struct Message {
pub subject: String,
pub reply: Option<String>,
pub data: Vec<u8>,
pub headers: Option<HeaderMap>,
/* private fields */
}
Expand description
A message received on a subject.
Fields
subject: String
The subject this message came from.
reply: Option<String>
Optional reply subject that may be used for sending a response to this message.
data: Vec<u8>
The message contents.
headers: Option<HeaderMap>
Optional headers associated with this Message
.
Implementations
sourceimpl Message
impl Message
sourcepub fn new(
subject: &str,
reply: Option<&str>,
data: impl AsRef<[u8]>,
headers: Option<HeaderMap>
) -> Message
pub fn new(
subject: &str,
reply: Option<&str>,
data: impl AsRef<[u8]>,
headers: Option<HeaderMap>
) -> Message
Creates new empty Message
, without a Client.
Useful for passing Message
data or creating Message
instance without caring about Client
,
but cannot be used on it’s own for associated methods as those require Client
injected into Message
and will error without it.
sourcepub fn is_no_responders(&self) -> bool
pub fn is_no_responders(&self) -> bool
Determine if the message is a no responders response from the server.
sourcepub fn ack(&self) -> Result<()>
pub fn ack(&self) -> Result<()>
Acknowledge a JetStream
message with a default acknowledgement.
See AckKind
documentation for details of what other types of
acks are available. If you need to send a non-default ack, use
the ack_kind
method below. If you need to block until the
server acks your ack, use the double_ack
method instead.
Returns immediately if this message has already been double-acked.
sourcepub fn ack_kind(&self, ack_kind: AckKind) -> Result<()>
pub fn ack_kind(&self, ack_kind: AckKind) -> Result<()>
Acknowledge a JetStream
message. See AckKind
documentation for
details of what each variant means. If you need to block until the
server acks your ack, use the double_ack
method instead.
Does not check whether this message has already been double-acked.
sourcepub fn double_ack(&self, ack_kind: AckKind) -> Result<()>
pub fn double_ack(&self, ack_kind: AckKind) -> Result<()>
Acknowledge a JetStream
message and wait for acknowledgement from the server
that it has received our ack. Retry acknowledgement until we receive a response.
See AckKind
documentation for details of what each variant means.
Returns immediately if this message has already been double-acked.
sourcepub fn jetstream_message_info(&self) -> Option<JetStreamMessageInfo<'_>>
pub fn jetstream_message_info(&self) -> Option<JetStreamMessageInfo<'_>>
Returns the JetStream
message ID
if this is a JetStream
message.
Returns None
if this is not
a JetStream
message with headers
set.
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more