Skip to main content

Group

Struct Group 

Source
pub struct Group<K, T, E, F, S = RandomState> { /* private fields */ }
Expand description

Namespace for duplicate suppression.

For a given key, only the leader computes. Duplicate callers subscribe to the leader’s broadcast and receive the same Outcome.

Implementations§

Source§

impl<K, T, E, F, Fut> Group<K, T, E, F, RandomState>
where F: Fn(K) -> Fut, Fut: Future<Output = Result<T, E>>,

Source

pub fn new(op: F) -> Self

Source§

impl<K, T, E, F, S> Group<K, T, E, F, S>

Source

pub fn with_hasher(op: F, hasher: S) -> Self

Source§

impl<K, T, E, F, S> Group<K, T, E, F, S>
where K: Eq + Hash, S: BuildHasher,

Source

pub fn entry(&self, key: K) -> Entry<K, T, E, S>

Returns a leader for a new key, or a subscriber for an in-flight key.

Source

pub async fn run<Fut>(&self, key: K) -> Arc<Outcome<T, E>>
where K: Clone, F: Fn(K) -> Fut, Fut: Future<Output = Result<T, E>>,

Executes this group’s operation once per key while an earlier call is in flight.

Source

pub fn forget<Q>(&self, key: &Q)
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Forgets a key so the next entry or run starts a fresh leader instead of joining the current call.

Source

pub fn in_flight(&self) -> usize

Trait Implementations§

Source§

impl<K, T, E, F, S> Clone for Group<K, T, E, F, S>

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

Auto Trait Implementations§

§

impl<K, T, E, F, S> Freeze for Group<K, T, E, F, S>

§

impl<K, T, E, F, S> RefUnwindSafe for Group<K, T, E, F, S>
where F: RefUnwindSafe,

§

impl<K, T, E, F, S> Send for Group<K, T, E, F, S>
where F: Sync + Send, S: Send, K: Send, T: Sync + Send, E: Sync + Send,

§

impl<K, T, E, F, S> Sync for Group<K, T, E, F, S>
where F: Sync + Send, S: Send, K: Send, T: Sync + Send, E: Sync + Send,

§

impl<K, T, E, F, S> Unpin for Group<K, T, E, F, S>

§

impl<K, T, E, F, S> UnsafeUnpin for Group<K, T, E, F, S>

§

impl<K, T, E, F, S> UnwindSafe for Group<K, T, E, F, S>
where F: RefUnwindSafe,

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, 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> 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 = 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.