Skip to main content

Consumer

Struct Consumer 

Source
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>

Source

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> Debug for Consumer<'_, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy> Drop for Consumer<'_, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: Copy> LatestSource<T> for Consumer<'_, T>

Source§

fn try_take_latest(&mut self) -> Option<LatestItem<T>>

Claim the newest unread publication, or return None when empty.

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for Consumer<'a, T>

§

impl<'a, T> !Sync for Consumer<'a, T>

§

impl<'a, T> !UnwindSafe for Consumer<'a, T>

§

impl<'a, T> Freeze for Consumer<'a, T>

§

impl<'a, T> Send for Consumer<'a, T>
where T: Send,

§

impl<'a, T> Unpin for Consumer<'a, T>

§

impl<'a, T> UnsafeUnpin for Consumer<'a, T>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.