1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use primitives::{Event};
use downcast::Downcast;
use std::any::Any;
pub trait BufferBase: Any + Sync + Send {
fn len(&self) -> usize;
fn clear(&mut self);
}
impl_downcast!(BufferBase);
downcast_methods!(BufferBase);
impl<B: BufferBase + ?Sized> BufferBase for Box<B> {
fn len(&self) -> usize { (**self).len() }
fn clear(&mut self){ (**self).clear() }
}
pub trait _EventBuffer<'a>: BufferBase {
type _Event: Event;
type Iter: Iterator<Item = &'a Self::_Event> + 'a;
}
pub trait EventBuffer: BufferBase
where Self: for<'a> _EventBuffer<'a, _Event = <Self as EventBuffer>::Event>
{
type Event: Event;
fn write<T>(&mut self, ev: T)
where T: Into<Self::Event>;
fn iter<'a>(&'a self) -> <Self as _EventBuffer<'a>>::Iter;
}