pub struct Consumer<'a, T: Copy> { /* private fields */ }Expand description
Unique, stateless read handle for a LatestBuf.
This handle is Send when T: Send (a non-Send payload correctly
pins it to one context) and always !Sync: it may move into a consumer
context, but it may not be shared between contexts (contract H2).
use ph_eventing::latest_buf::Consumer;
fn assert_sync<T: Sync>() {}
assert_sync::<Consumer<'static, u32>>();§No Source<T> implementation — by decision, not omission
Source::try_pop cannot report the displacement that is this channel’s
designed overload behaviour, so a generic pipeline would silently
discard loss evidence during normal operation (decision D2; contract
non-promise X7). crate::LatestSource is the consumer’s designed
contract surface. A caller whose domain genuinely permits discarding
the skipped count writes its own adapter, so the discard is signed in
application code, never by the transport. This compile_fail doctest
pins the absent impl so a convenience Source cannot arrive silently,
and pinning the error code keeps it honest:
use ph_eventing::Source;
let channel = ph_eventing::LatestBuf::<u32>::new();
let mut consumer = channel.try_consumer().unwrap();
let _ = Source::try_pop(&mut consumer);Implementations§
Source§impl<T: Copy> Consumer<'_, T>
impl<T: Copy> Consumer<'_, T>
Sourcepub fn take_latest(&self) -> Option<LatestItem<T>>
pub fn take_latest(&self) -> Option<LatestItem<T>>
Claim and copy the latest unread publication.
Returns None when no publication is pending. The operation performs
an Acquire load first, so an empty poll returns without an atomic
read-modify-write. A pending publication is still claimed with the
ownership-transferring AcqRel swap.
Trait Implementations§
Source§impl<T: Copy> LatestSource<T> for Consumer<'_, T>
impl<T: Copy> LatestSource<T> for Consumer<'_, T>
Source§fn try_take_latest(&mut self) -> Option<LatestItem<T>>
fn try_take_latest(&mut self) -> Option<LatestItem<T>>
None when empty.