pub struct JetStreamContext { /* private fields */ }Expand description
Native JetStream per-delivery metadata, built once per delivery from the broker message.
Read its fields by the compile-time keys (for example
keys::STREAM_SEQUENCE). On a core (non-JetStream) delivery there is no such metadata, so the
context is empty and every key reads None; the same handler therefore works on both kinds of
subscription.
The context owns its fields (it copies them out of the delivery), so it does not borrow the message: numbers are a stack copy and the stream/consumer names are cloned once per delivery.
§Examples
use ruststream::runtime::Context;
use ruststream_nats::context::{JetStreamContext, keys};
// The context a handler reads through; the runtime supplies it per delivery.
fn read(ctx: &Context<'_, JetStreamContext>) -> Option<u64> {
ctx.context(keys::STREAM_SEQUENCE)
}Trait Implementations§
Source§impl BuildContext<NatsMessage> for JetStreamContext
impl BuildContext<NatsMessage> for JetStreamContext
Source§fn build(msg: &NatsMessage) -> Self
fn build(msg: &NatsMessage) -> Self
Builds the context value by reading fields out of
msg.Source§impl Clone for JetStreamContext
impl Clone for JetStreamContext
Source§fn clone(&self) -> JetStreamContext
fn clone(&self) -> JetStreamContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JetStreamContext
impl Debug for JetStreamContext
Source§impl Default for JetStreamContext
impl Default for JetStreamContext
Source§fn default() -> JetStreamContext
fn default() -> JetStreamContext
Returns the “default value” for a type. Read more
impl Eq for JetStreamContext
Source§impl Field<JetStreamContext> for StreamSequence
impl Field<JetStreamContext> for StreamSequence
Source§impl Field<JetStreamContext> for ConsumerSequence
impl Field<JetStreamContext> for ConsumerSequence
Source§impl Field<JetStreamContext> for Delivered
impl Field<JetStreamContext> for Delivered
Source§impl Field<JetStreamContext> for Pending
impl Field<JetStreamContext> for Pending
Source§impl Field<JetStreamContext> for Stream
impl Field<JetStreamContext> for Stream
Source§impl Field<JetStreamContext> for Consumer
impl Field<JetStreamContext> for Consumer
Source§impl PartialEq for JetStreamContext
impl PartialEq for JetStreamContext
Source§fn eq(&self, other: &JetStreamContext) -> bool
fn eq(&self, other: &JetStreamContext) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for JetStreamContext
Auto Trait Implementations§
impl Freeze for JetStreamContext
impl RefUnwindSafe for JetStreamContext
impl Send for JetStreamContext
impl Sync for JetStreamContext
impl Unpin for JetStreamContext
impl UnsafeUnpin for JetStreamContext
impl UnwindSafe for JetStreamContext
Blanket Implementations§
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