use std::sync::Arc;
use error::ErrorKind;
pub trait Listener<T> {
fn added(&mut self, _tx: &Arc<T>, _old: Option<&Arc<T>>) {}
fn rejected(&mut self, _tx: &Arc<T>, _reason: &ErrorKind) {}
fn dropped(&mut self, _tx: &Arc<T>, _by: Option<&T>) {}
fn invalid(&mut self, _tx: &Arc<T>) {}
fn canceled(&mut self, _tx: &Arc<T>) {}
fn mined(&mut self, _tx: &Arc<T>) {}
}
#[derive(Debug)]
pub struct NoopListener;
impl<T> Listener<T> for NoopListener {}
impl<T, A, B> Listener<T> for (A, B) where
A: Listener<T>,
B: Listener<T>,
{
fn added(&mut self, tx: &Arc<T>, old: Option<&Arc<T>>) {
self.0.added(tx, old);
self.1.added(tx, old);
}
fn rejected(&mut self, tx: &Arc<T>, reason: &ErrorKind) {
self.0.rejected(tx, reason);
self.1.rejected(tx, reason);
}
fn dropped(&mut self, tx: &Arc<T>, by: Option<&T>) {
self.0.dropped(tx, by);
self.1.dropped(tx, by);
}
fn invalid(&mut self, tx: &Arc<T>) {
self.0.invalid(tx);
self.1.invalid(tx);
}
fn canceled(&mut self, tx: &Arc<T>) {
self.0.canceled(tx);
self.1.canceled(tx);
}
fn mined(&mut self, tx: &Arc<T>) {
self.0.mined(tx);
self.1.mined(tx);
}
}