GetUpdate

Trait GetUpdate 

Source
pub trait GetUpdate {
    type G;
    type U;

    // Required methods
    fn get(&mut self) -> Option<Self::G>;
    fn update(&mut self, u: Self::U) -> Unblocked;

    // Provided method
    fn update_multiples(
        &mut self,
        us: impl IntoIterator<Item = Self::U>,
    ) -> Unblocked { ... }
}
Expand description

Where your shared state logic should be implemented

GetUpdate represents the shared state of your logic.

§In progress

This trait can mostly be approached from a sequential (ie. not multi-thread) point of view, except for one thing: one can now observe unit of work being in progress. Or rather, one can call get and get a unit of work to process while another thread is still processing a previous unit of work returned by get. In some cases, your state should represent units of work being processed but not finished yet for your application logic to be correct.

Required Associated Types§

Source

type G

The return type of GetUpdate::get

Source

type U

Required Methods§

Source

fn get(&mut self) -> Option<Self::G>

Returns a unit of work to be processed, if there is one left

Source

fn update(&mut self, u: Self::U) -> Unblocked

Updated the state, returning an upper bound of how many new units of works were made available by this update.

Provided Methods§

Source

fn update_multiples( &mut self, us: impl IntoIterator<Item = Self::U>, ) -> Unblocked

Updated the state with several updates, returning an upper bound of how many new units of works were made available by all these update.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> GetUpdate for VecDeque<T>

Source§

type G = T

Source§

type U = T

Source§

fn get(&mut self) -> Option<Self::G>

Source§

fn update(&mut self, u: Self::U) -> Unblocked

Source§

fn update_multiples( &mut self, us: impl IntoIterator<Item = Self::U>, ) -> Unblocked

Source§

impl<T> GetUpdate for Vec<T>

Source§

type G = T

Source§

type U = T

Source§

fn get(&mut self) -> Option<Self::G>

Source§

fn update(&mut self, u: Self::U) -> Unblocked

Source§

fn update_multiples( &mut self, us: impl IntoIterator<Item = Self::U>, ) -> Unblocked

Implementors§

Source§

impl<GU: GetUpdate> GetUpdate for HashSetDedupOnGet<GU>
where GU::G: Clone + Hash + Eq,

Source§

type G = <GU as GetUpdate>::G

Source§

type U = <GU as GetUpdate>::U

Source§

impl<GU: GetUpdate> GetUpdate for HashSetDedupOnUpdate<GU>
where GU::U: Clone + Hash + Eq,

Source§

type G = <GU as GetUpdate>::G

Source§

type U = <GU as GetUpdate>::U

Source§

impl<Prio: Ord, T> GetUpdate for PrioQueue<Prio, T>