Trait runa_core::Serial

source ·
pub trait Serial {
    type Data;
    type Iter<'a>: Iterator<Item = (u32, &'a Self::Data)>
       where Self: 'a,
             Self::Data: 'a;

    // Required methods
    fn next_serial(&mut self, data: Self::Data) -> u32;
    fn get(&self, serial: u32) -> Option<&Self::Data>;
    fn iter(&self) -> Self::Iter<'_>;
    fn expire(&mut self, serial: u32) -> bool;
}
Expand description

Event serial management. (WIP, not currently used)

This trait allocates serial numbers, while keeping track of allocated numbers and their associated data.

Some expiration scheme might be employed by the implementation to free up old serial numbers.

TODO: this is incomplete and not used.

Required Associated Types§

source

type Data

source

type Iter<'a>: Iterator<Item = (u32, &'a Self::Data)> where Self: 'a, Self::Data: 'a

Required Methods§

source

fn next_serial(&mut self, data: Self::Data) -> u32

Get the next serial number in sequence. A piece of data can be attached to each serial, storing, for example, what this event is about.

source

fn get(&self, serial: u32) -> Option<&Self::Data>

Get the data associated with the given serial.

source

fn iter(&self) -> Self::Iter<'_>

source

fn expire(&mut self, serial: u32) -> bool

Remove the serial number from the list of allocated serials.

Implementors§