File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ use core:: fmt:: { Debug } ;
2+
3+ use serde_:: { Serialize , Deserialize } ;
4+
5+ pub trait Protocol < Id > {
6+ type ProtocolError : ProtocolError < Id > ;
7+ }
8+
9+ pub trait ProtocolError < Id > : Debug + Clone + Serialize + for < ' de > Deserialize < ' de > { }
10+
11+ /// A trait defining two protocols executed sequentially.
12+ pub trait ChainedProtocol < Id > : ' static + Debug {
13+ type Protocol1 : Protocol < Id > ;
14+ }
15+
16+ /// The protocol error type for the chained protocol.
17+ #[ derive_where:: derive_where( Debug , Clone ) ]
18+ #[ derive( Serialize , Deserialize ) ]
19+ #[ serde( crate = "serde_" ) ]
20+ #[ serde( bound( serialize = "
21+ <C::Protocol1 as Protocol<Id>>::ProtocolError: Serialize,
22+ " ) ) ]
23+ #[ serde( bound( deserialize = "
24+ <C::Protocol1 as Protocol<Id>>::ProtocolError: for<'x> Deserialize<'x>,
25+ " ) ) ]
26+ pub enum ChainedProtocolError < Id , C >
27+ where
28+ C : ChainedProtocol < Id > ,
29+ {
30+ Protocol1 ( <C :: Protocol1 as Protocol < Id > >:: ProtocolError ) ,
31+ }
32+
33+ impl < Id , C > ProtocolError < Id > for ChainedProtocolError < Id , C >
34+ where
35+ C : ChainedProtocol < Id > ,
36+ {
37+
38+ }
You can’t perform that action at this time.
0 commit comments