Skip to main content

SessionMessage

Trait SessionMessage 

Source
pub trait SessionMessage:
    Sized
    + Debug
    + HeaderAccess {
    // Required methods
    fn from_raw_message(
        raw: RawMessage<'_>,
    ) -> Result<Box<Self>, DeserializeError>;
    fn serialize(&self, buf: &mut [u8]) -> Result<usize, SerializeError>;
    fn header(&self) -> HeaderBase<'_>;
    fn try_as_admin(&self) -> Option<AdminBase<'_>>;
    fn msg_type(&self) -> MsgTypeField;
    fn msg_cat(&self) -> MsgCat;
    fn name(&self) -> &'static str;
    fn from_admin(
        header: HeaderBase<'static>,
        admin: AdminBase<'static>,
    ) -> Self;

    // Provided method
    fn from_bytes(bytes: &[u8]) -> Result<Box<Self>, DeserializeError> { ... }
}
Expand description

Core message trait that bridges session logic and concrete message types.

The session layer uses this trait to deserialize, inspect, construct, and serialize messages without knowing the concrete type.

Required Methods§

Source

fn from_raw_message(raw: RawMessage<'_>) -> Result<Box<Self>, DeserializeError>

Deserialize from a structurally validated RawMessage.

On failure the DeserializeError carries the parsed header whenever header parsing succeeded before the failure.

Source

fn serialize(&self, buf: &mut [u8]) -> Result<usize, SerializeError>

Serialize to FIX tag-value wire format into the caller-provided buffer. Returns the number of bytes written.

Source

fn header(&self) -> HeaderBase<'_>

Extract header fields as a borrowed base. Zero-copy.

Source

fn try_as_admin(&self) -> Option<AdminBase<'_>>

If this is an admin message, return the borrowed base. Zero-copy.

Source

fn msg_type(&self) -> MsgTypeField

Compact message type identifier (e.g. "A" for Logon, "D" for NewOrderSingle).

Compare against MsgTypeBase variants for admin dispatch, or TryFrom into a richer generated type for exhaustive matching - fallible, since the field may hold a value that type does not define.

Source

fn msg_cat(&self) -> MsgCat

Whether this is an admin or application message.

Source

fn name(&self) -> &'static str

Human-readable message name (e.g., "Logon", "NewOrderSingle").

Source

fn from_admin(header: HeaderBase<'static>, admin: AdminBase<'static>) -> Self

Build an outgoing admin message from owned base messages.

Provided Methods§

Source

fn from_bytes(bytes: &[u8]) -> Result<Box<Self>, DeserializeError>

Deserialize from FIX tag-value wire bytes. Composes raw_message framing with Self::from_raw_message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§