#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.header: BytesThe frame’s header bytes.
payload: BytesThe frame’s payload bytes.
guard: InFlightGuardKeeps the instance’s in-flight count non-zero for as long as this message exists, queued or in a handler.
Implementations§
Source§impl InboundMessage
impl InboundMessage
Sourcepub fn new(header: Bytes, payload: Bytes, guard: InFlightGuard) -> Self
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.