Skip to main content

InboundMessage

Struct InboundMessage 

Source
#[non_exhaustive]
pub struct InboundMessage { pub header: Bytes, pub payload: Bytes, pub guard: InFlightGuard, }
Expand description

An inbound MessageType::Message frame together with the in-flight guard that makes it visible to ShutdownState::wait_for_drain.

The guard is mandatory, which is the whole point of the type: a message cannot sit on the inbound queue without being counted work. Producers never build one directly — TransportAdapter::admit_message acquires the guard and constructs it, and the message channel’s sender is private so there is no other way in. Whatever happens to the message afterwards — dispatched, dropped on a decode error, handed back undelivered when the receiver has gone, discarded by a consumer that is abandoning its backlog at teardown — the guard rides along and its Drop releases the count. “Queued implies counted” is therefore an invariant of the type system, not a convention producers have to honour.

The one thing that does not release a guard is walking away from the channel: flume frees buffered items only once the last endpoint is gone, so a consumer that stops receiving while transports still hold sender clones must drain and drop what it is abandoning, not merely drop its receiver.

#[non_exhaustive]: construct with InboundMessage::new, match with a trailing ...

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.
§header: Bytes

The frame’s header bytes.

§payload: Bytes

The frame’s payload bytes.

§guard: InFlightGuard

Keeps the instance’s in-flight count non-zero for as long as this message exists, queued or in a handler.

Implementations§

Source§

impl InboundMessage

Source

pub fn new(header: Bytes, payload: Bytes, guard: InFlightGuard) -> Self

Bind a frame to an already-acquired in-flight guard.

Public for consumer-side fabrication — a test that wants a realistic item to feed a receiver, or a harness that stands in for the runtime. It is not a way onto the inbound queue: the channel’s sender is private, so producers still go through TransportAdapter::admit_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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.