Counter

Trait Counter 

Source
pub trait Counter {
    type Value;

    // Required methods
    fn decrease();
    fn get() -> Self::Value;
    fn increase();
    fn reset();
}
Expand description

Represents logic of managing step-by-step changeable value.

Required Associated Types§

Source

type Value

Counter stored type.

Required Methods§

Source

fn decrease()

Decreases stored value.

Should be safe from overflow.

Source

fn get() -> Self::Value

Returns stored value, if present, or default/starting value.

Source

fn increase()

Increases stored value.

Should be safe from overflow.

Source

fn reset()

Resets stored value by setting default/starting value.

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.

Implementors§

Source§

impl<VS: ValueStorage<Value = i8>> Counter for CounterImpl<i8, VS>

Source§

impl<VS: ValueStorage<Value = i16>> Counter for CounterImpl<i16, VS>

Source§

impl<VS: ValueStorage<Value = i32>> Counter for CounterImpl<i32, VS>

Source§

impl<VS: ValueStorage<Value = i64>> Counter for CounterImpl<i64, VS>

Source§

impl<VS: ValueStorage<Value = i128>> Counter for CounterImpl<i128, VS>

Source§

impl<VS: ValueStorage<Value = u8>> Counter for CounterImpl<u8, VS>

Source§

impl<VS: ValueStorage<Value = u16>> Counter for CounterImpl<u16, VS>

Source§

impl<VS: ValueStorage<Value = u32>> Counter for CounterImpl<u32, VS>

Source§

impl<VS: ValueStorage<Value = u64>> Counter for CounterImpl<u64, VS>

Source§

impl<VS: ValueStorage<Value = u128>> Counter for CounterImpl<u128, VS>