[][src]Trait spartan_lib::core::dispatcher::Delete

pub trait Delete<M>: SimpleDispatcher<M> where
    M: Dispatchable
{ pub fn delete(&mut self, id: <M as Identifiable>::Id) -> Option<M>; }

Interface for deleting messages from queue, where database position key is not the same, as message ID

It is preferable to use PositionBasedDelete instead of Delete

Required methods

pub fn delete(&mut self, id: <M as Identifiable>::Id) -> Option<M>[src]

Delete message from queue

Returns owned message if id is present in database

use spartan_lib::core::dispatcher::{SimpleDispatcher, Delete};
use spartan_lib::core::db::VecDatabase;
use spartan_lib::core::message::builder::MessageBuilder;
use spartan_lib::core::payload::Identifiable;

let mut db = VecDatabase::default();
let message = MessageBuilder::default().body("Hello, world").compose().unwrap();

db.push(message.clone());

assert_eq!(db.size(), 1);

assert_eq!(db.delete(message.id()).unwrap().id(), message.id());

assert_eq!(db.size(), 0);
Loading content...

Implementors

impl<T, M> Delete<M> for T where
    T: Database<M>,
    M: Dispatchable
[src]

Loading content...