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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use std::fmt::Debug;
use crate::{
algebra::{signature::Signature, Matcher},
claims::{Claim, SecurityViolationPolicy},
codec::Codec,
error::Error,
trace::{Knowledge, Source, Trace},
};
pub trait ExtractKnowledge<M: Matcher>: std::fmt::Debug {
fn extract_knowledge(
&self,
knowledges: &mut Vec<Knowledge<M>>,
matcher: Option<M>,
source: &Source,
) -> Result<(), Error>;
}
pub trait ProtocolMessageFlight<
Mt: Matcher,
M: ProtocolMessage<Mt, O>,
O: OpaqueProtocolMessage<Mt>,
OF: OpaqueProtocolMessageFlight<Mt, O>,
>: Clone + Debug + From<M> + TryFrom<OF> + Into<OF> + ExtractKnowledge<Mt>
{
fn new() -> Self;
fn push(&mut self, msg: M);
fn debug(&self, info: &str);
}
pub trait OpaqueProtocolMessageFlight<Mt: Matcher, O: OpaqueProtocolMessage<Mt>>:
Clone + Debug + Codec + From<O> + ExtractKnowledge<Mt>
{
fn new() -> Self;
fn debug(&self, info: &str);
fn push(&mut self, msg: O);
}
pub trait ProtocolMessage<Mt: Matcher, O: OpaqueProtocolMessage<Mt>>:
Clone + Debug + ExtractKnowledge<Mt>
{
fn create_opaque(&self) -> O;
fn debug(&self, info: &str);
}
pub trait OpaqueProtocolMessage<Mt: Matcher>: Clone + Debug + Codec + ExtractKnowledge<Mt> {
fn debug(&self, info: &str);
}
pub trait ProtocolMessageDeframer<Mt: Matcher> {
type OpaqueProtocolMessage: OpaqueProtocolMessage<Mt>;
fn pop_frame(&mut self) -> Option<Self::OpaqueProtocolMessage>;
fn read(&mut self, rd: &mut dyn std::io::Read) -> std::io::Result<usize>;
}
pub trait ProtocolBehavior: 'static {
type Matcher: Matcher;
type Claim: Claim;
type SecurityViolationPolicy: SecurityViolationPolicy<Self::Claim>;
type ProtocolMessage: ProtocolMessage<Self::Matcher, Self::OpaqueProtocolMessage>;
type OpaqueProtocolMessage: OpaqueProtocolMessage<Self::Matcher>;
type ProtocolMessageFlight: ProtocolMessageFlight<
Self::Matcher,
Self::ProtocolMessage,
Self::OpaqueProtocolMessage,
Self::OpaqueProtocolMessageFlight,
>;
type OpaqueProtocolMessageFlight: OpaqueProtocolMessageFlight<Self::Matcher, Self::OpaqueProtocolMessage>
+ From<Self::ProtocolMessageFlight>;
fn signature() -> &'static Signature;
fn create_corpus() -> Vec<(Trace<Self::Matcher>, &'static str)>;
}