use std::ops::{Deref, DerefMut};
use crate::Log;
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
pub struct Events {
events: Vec<Event>,
}
impl Events {
pub fn new() -> Self {
Self { events: Vec::new() }
}
pub fn push(&mut self, event: Event) {
self.events.push(event);
}
pub fn into_inner(self) -> Vec<Event> {
self.events
}
pub fn len(&self) -> usize {
self.events.len()
}
pub fn is_empty(&self) -> bool {
self.events.is_empty()
}
}
impl Deref for Events {
type Target = Vec<Event>;
fn deref(&self) -> &Self::Target {
&self.events
}
}
impl DerefMut for Events {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.events
}
}
impl From<Vec<Event>> for Events {
fn from(events: Vec<Event>) -> Self {
Self { events }
}
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct Event {
pub log: Log,
}
impl Event {
pub fn new(log: Log) -> Self {
Self { log }
}
}