Message

Trait Message 

Source
pub trait Message: Sized + Debug {
    const ID: u64;

    // Required methods
    fn encode_msg<W: BufMut>(&self, w: &mut W, version: Version);
    fn decode_msg<B: Buf>(
        buf: &mut B,
        version: Version,
    ) -> Result<Self, DecodeError>;
}
Expand description

A trait for messages that are size-prefixed during encoding/decoding.

This trait wraps the existing Encode/Decode traits and automatically handles:

  • Prefixing messages with their encoded size during encoding
  • Reading the size prefix and validating exact consumption during decoding
  • Ensuring no bytes are left over or missing after decoding

Required Associated Constants§

Source

const ID: u64

Required Methods§

Source

fn encode_msg<W: BufMut>(&self, w: &mut W, version: Version)

Encode this message with a size prefix.

Source

fn decode_msg<B: Buf>( buf: &mut B, version: Version, ) -> Result<Self, DecodeError>

Decode a size-prefixed message, ensuring exact size consumption.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Message for ClientSetup

Source§

const ID: u64 = 32u64

Source§

impl Message for FetchCancel

Source§

const ID: u64 = 23u64

Source§

impl Message for FetchOk

Source§

const ID: u64 = 24u64

Source§

impl Message for MaxRequestId

Source§

const ID: u64 = 21u64

Source§

impl Message for PublishNamespaceOk

Source§

const ID: u64 = 7u64

Source§

impl Message for PublishOk

Source§

const ID: u64 = 30u64

Source§

impl Message for RequestsBlocked

Source§

const ID: u64 = 26u64

Source§

impl Message for ServerSetup

Source§

const ID: u64 = 33u64

Source§

impl Message for SubscribeNamespaceOk

Source§

const ID: u64 = 18u64

Source§

impl Message for SubscribeOk

Source§

const ID: u64 = 4u64

Source§

impl Message for SubscribeUpdate

Source§

const ID: u64 = 2u64

Source§

impl Message for Unsubscribe

Source§

const ID: u64 = 10u64

Source§

impl Message for UnsubscribeNamespace

Source§

const ID: u64 = 20u64

Source§

impl<'a> Message for Fetch<'a>

Source§

const ID: u64 = 22u64

Source§

impl<'a> Message for FetchError<'a>

Source§

const ID: u64 = 25u64

Source§

impl<'a> Message for GoAway<'a>

Source§

const ID: u64 = 16u64

Source§

impl<'a> Message for Publish<'a>

Source§

const ID: u64 = 29u64

Source§

impl<'a> Message for PublishDone<'a>

Source§

const ID: u64 = 11u64

Source§

impl<'a> Message for PublishError<'a>

Source§

const ID: u64 = 31u64

Source§

impl<'a> Message for PublishNamespace<'a>

Source§

const ID: u64 = 6u64

Source§

impl<'a> Message for PublishNamespaceCancel<'a>

Source§

const ID: u64 = 12u64

Source§

impl<'a> Message for PublishNamespaceDone<'a>

Source§

const ID: u64 = 9u64

Source§

impl<'a> Message for PublishNamespaceError<'a>

Source§

const ID: u64 = 8u64

Source§

impl<'a> Message for Subscribe<'a>

Source§

const ID: u64 = 3u64

Source§

impl<'a> Message for SubscribeError<'a>

Source§

const ID: u64 = 5u64

Source§

impl<'a> Message for SubscribeNamespace<'a>

Source§

const ID: u64 = 17u64

Source§

impl<'a> Message for SubscribeNamespaceError<'a>

Source§

const ID: u64 = 19u64

Source§

impl<'a> Message for TrackStatus<'a>

Source§

const ID: u64 = 13u64