Skip to main content

Consumer

Struct Consumer 

Source
pub struct Consumer { /* private fields */ }
Expand description

A lazy handle to a single track within a broadcast.

Obtained from broadcast::Consumer::track. Holding it sends nothing and is not Demand: the track is requested, and counts as demanded, only while an info, subscribe (a live, ongoing stream of groups), or fetch_group (one group) made from it is held. The same handle can be used any number of times, and clones are cheap.

Implementations§

Source§

impl Consumer

Source

pub fn unmetered(self) -> Self

This handle with its stats scope cleared, so the subscriptions, fetches, and groups derived from it count toward no stats session: for reads a consumer makes for itself rather than on behalf of whoever its origin is metered for.

Source

pub fn name(&self) -> &str

The track name this handle is bound to.

Source

pub fn broadcast(&self) -> &Info

The broadcast this track belongs to, as reached through the handle it came from. Its path is what a catalog’s relative broadcast references resolve against.

Source

pub fn subscribe( &self, subscription: impl Into<Option<Subscription>>, ) -> Pending<Subscribing> ⓘ

Open a live subscription.

Registers the subscription on the track and returns a [kio::Pending] that resolves to the Subscriber once the track info is available, or the track’s abort error (or Error::Dropped) if it is already closed.

Reads only the groups the subscription’s ranges cover. A group reached only through live joins is skipped once the widest of their max convicts it, so the default Start::LATEST delivers only the latest group; a history range delivers every group it covers.

Source

pub fn fetch_group( &self, key: u64, options: impl Into<Option<Fetch>>, ) -> Pending<Fetching> ⓘ

Fetching a single past group, without holding a live subscription.

Returns a [kio::Pending] that resolves to the group::Consumer: immediately if the group is cached, otherwise once a Requests serves the request (a wire FETCH for a relay). options accepts None, a group::Fetch, or group::Fetch::default().

The returned future resolves to Error::NotFound when the group can never be served (past the final key, or no Requests on the track), the handler’s rejection (a relay’s upstream miss is StreamError::NotFound), or the track’s abort error if it’s already closed. A miss queues a one-group FillGroups, which concurrent fetches of the same key join. A key past the live edge of a track fed over lite-07 waits for the group, as a subscription would; the track’s own publisher asks its Requests for it at once.

Source

pub fn info(&self) -> Pending<Resolving> ⓘ

Resolve the track’s Info without subscribing.

A Consumer is a lazy handle, so the info may not be known yet: this waits for the producer to Request::accept the track (a wire TRACK_INFO round-trip for a relay), and errors with the track’s abort error if it closes first. Subscriber::info is the already-resolved counterpart.

Source

pub fn poll_largest(&mut self, waiter: &Waiter) -> Poll<Option<Position>>

The track’s largest location, its newest group at the newest frame (0 while empty): the current one, then each newer one, and None once the track ends.

Source

pub async fn largest(&mut self) -> Option<Position>

The track’s largest location, its newest group at the newest frame (0 while empty): the current one, then each newer one, and None once the track ends.

Awaits poll_largest.

Trait Implementations§

Source§

impl Clone for Consumer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Consume<Consumer> for Producer

Source§

fn consume(&self) -> Consumer

Derive a read view (a consumer) from this handle.
Source§

impl Consume<Consumer> for Consumer

Source§

fn consume(&self) -> Consumer

Derive a read view (a consumer) from this handle.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more