Skip to main content

UnknownTemplateMessage

Struct UnknownTemplateMessage 

Source
#[non_exhaustive]
pub struct UnknownTemplateMessage { pub template_id: i32, pub payload: Bytes, }
Expand description

A frame whose template_id this crate has no message definition for.

The payload is kept as received, so a template this crate doesn’t map can still be handled downstream: decode_as decodes it into a type you generate yourself, and payload_hex dumps it for later.

§Examples

A frame off a subscription stream arrives as RithmicMessage::UnknownTemplate with error: None. Log it, then decode it into a type generated in your own crate from the .proto; crate::prost is re-exported so the generated code can’t drift from the version this crate decodes with.

use rithmic_rs::prost;
use rithmic_rs::rti::messages::RithmicMessage;

// Generated in your crate by prost-build, once you know what 358 maps to.
#[derive(Clone, PartialEq, prost::Message)]
pub struct Template358 {
    #[prost(string, optional, tag = "110100")]
    pub symbol: Option<String>,
}

fn on_message(message: &RithmicMessage) {
    let RithmicMessage::UnknownTemplate(frame) = message else {
        return;
    };

    // template_id=358 (84 bytes) a2e135054d45535536aae13503434d45…+52B
    tracing::warn!(payload = %frame.payload_hex(), "unmapped template: {frame}");

    if frame.template_id == 358 {
        if let Ok(decoded) = frame.decode_as::<Template358>() {
            println!("{:?}", decoded.symbol);
        }
    }
}

payload_hex is untruncated, so a frame captured in production can be replayed in a test through from_payload_hex.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§template_id: i32

The template_id read from the frame header.

§payload: Bytes

The complete message body, exactly as received.

Only the 4-byte big-endian length prefix is stripped, as every other decoder here does; it carries nothing beyond payload.len().

Implementations§

Source§

impl UnknownTemplateMessage

Source

pub fn new(template_id: i32, payload: Bytes) -> Self

Build a frame from its template_id and body.

Source

pub fn decode_as<M: Message + Default>(&self) -> Result<M, DecodeError>

Decode the payload into a caller-supplied protobuf type.

Generate the type from the .proto in your own crate and decode into it. Uses the crate::prost re-export, so types generated against rithmic_rs::prost are compatible by construction.

§Errors

prost::DecodeError when the bytes are structurally incompatible with M, such as a wire-type conflict on a field M declares.

Ok is not proof the type was guessed right. Protobuf skips fields the target doesn’t declare, so an unrelated payload usually decodes into a mostly-empty value.

Source

pub fn payload_hex(&self) -> String

The whole payload as lowercase hex, no truncation, no 0x prefix.

Display elides the payload to stay readable in a log line; this doesn’t.

Source

pub fn from_payload_hex(template_id: i32, hex: &str) -> Option<Self>

Rebuild a frame from a payload_hex dump.

Ignores a leading 0x and any whitespace, including newlines from a wrapped log line. None unless hex holds an even number of hex digits; empty input yields an empty payload.

Trait Implementations§

Source§

impl Clone for UnknownTemplateMessage

Source§

fn clone(&self) -> UnknownTemplateMessage

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 UnknownTemplateMessage

Source§

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

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

impl Display for UnknownTemplateMessage

Source§

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

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

impl Eq for UnknownTemplateMessage

Source§

impl PartialEq for UnknownTemplateMessage

Source§

fn eq(&self, other: &UnknownTemplateMessage) -> 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 UnknownTemplateMessage

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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