Skip to main content

Message

Struct Message 

Source
pub struct Message { /* private fields */ }
Expand description

A message on its way to the server’s Metadata Adapter.

There are two shapes, and the difference is not cosmetic:

  • Message::new — numbered, so the server can deduplicate it and so its outcome can be reported back to you.
  • Message::fire_and_forget — unnumbered and unreported. The server cannot tell a resend from a new message and you will never learn whether it worked.

§The number is yours to choose

The progressive starts at 1 and orders the messages of a sequence. This crate deliberately does not allocate it: the server tracks the numbering per session, so a counter kept here would silently restart the moment a session was replaced — exactly when a caller most needs to know what happened to a message. You own the numbering, and this crate never rewrites it.

§Examples

use std::num::NonZeroU32;
use lightstreamer_rs::{Message, SequenceName as Sequence};

let message = Message::new("BUY 100", NonZeroU32::MIN)
    .in_sequence(Sequence::try_new("ORDERS")?);

Implementations§

Source§

impl Message

Source

pub fn new(text: impl Into<String>, progressive: NonZeroU32) -> Self

A numbered message whose outcome will be reported.

The outcome arrives on the session event stream as SessionEvent::Message.

Source

pub fn fire_and_forget(text: impl Into<String>) -> Self

A message with no number and no outcome report.

The protocol makes these two properties inseparable: a message may omit its progressive only if it also declines the outcome notification [docs/spec/03-requests.md §12.1]. So this is genuinely fire-and-forget — no ordering, no deduplication, no confirmation, and no error if the Metadata Adapter rejects it.

Source

pub fn in_sequence(self, sequence: SequenceName) -> Self

Places the message in an ordered sequence.

Messages of one sequence are processed in progressive order; messages of different sequences do not constrain each other.

Source

pub fn with_max_wait(self, wait: Duration) -> Result<Self, ConfigError>

How long the server may wait for earlier messages of the same sequence before giving up on them and processing this one [docs/spec/03-requests.md §12.1].

Only meaningful alongside Message::in_sequence. When the wait expires the skipped progressives are reported as failures with Appendix B codes 38 and 39 [docs/spec/05-error-codes.md §2].

§Errors

ConfigError::DurationTooLarge if the duration does not fit a whole number of milliseconds.

Source

pub fn text(&self) -> &str

The text that will be delivered.

Source

pub fn validate(&self) -> Result<(), ConfigError>

Checks that the parts of this message can be sent together.

Client::send_message calls this first, so a caller never has to; it is public for the same reason Subscription::validate is.

§Errors
  • ConfigError::SequencedMessageNeedsAProgressive if a Message::fire_and_forget message was placed in a sequence. A sequence orders messages by their progressive, and a fire-and-forget message has none: LS_msg_prog is “mandatory whenever LS_sequence is specified” [docs/spec/03-requests.md §12.1]. The two are not a combination the protocol leaves open.
  • ConfigError::MaxWaitNeedsASequence if Message::with_max_wait was used on a message in no sequence, where it names how long to wait for messages that do not exist. The server ignores it there [docs/spec/03-requests.md §12.1]; this crate refuses it, so that a caller who set a bound is never silently running without one.
§Examples
use lightstreamer_rs::{ConfigError, Message, SequenceName};

let impossible = Message::fire_and_forget("BUY 100")
    .in_sequence(SequenceName::try_new("ORDERS")?);

assert!(matches!(
    impossible.validate(),
    Err(ConfigError::SequencedMessageNeedsAProgressive)
));

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

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 Debug for Message

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Message

Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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