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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(not(feature = "std"))]
use crate::no_std_prelude::*;
use crate::{Bytes, Hash, Result, Token, TopicFilter};
pub trait LogFilter {
fn wildcard_filter(&self) -> TopicFilter;
}
pub trait ParseLog {
type Log;
fn parse_log(&self, log: RawLog) -> Result<Self::Log>;
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct RawLog {
pub topics: Vec<Hash>,
pub data: Bytes,
}
impl From<(Vec<Hash>, Bytes)> for RawLog {
fn from(raw: (Vec<Hash>, Bytes)) -> Self {
RawLog { topics: raw.0, data: raw.1 }
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Clone)]
pub struct LogParam {
pub name: String,
pub value: Token,
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Clone)]
pub struct Log {
pub params: Vec<LogParam>,
}