@@ -37,9 +37,9 @@ enum SnifferError {
37
37
/// The downstream (or client) role connects to the [`Sniffer`] `listening_address` and the
38
38
/// [`Sniffer`] connects to the `upstream` server. This way, the Sniffer can intercept messages sent
39
39
/// between the downstream and upstream roles. The downstream will send its messages to the
40
- /// [`Sniffer`] which will save those in the `downstream_messages ` aggregator and forward them to
41
- /// the upstream role. When a response is received it is saved in `upstream_messages ` and
42
- /// forwarded to the downstream role. Both `downstream_messages ` and `upstream_messages ` can be
40
+ /// [`Sniffer`] which will save those in the `messages_from_downstream ` aggregator and forward them to
41
+ /// the upstream role. When a response is received it is saved in `messages_from_upstream ` and
42
+ /// forwarded to the downstream role. Both `messages_from_downstream ` and `messages_from_upstream ` can be
43
43
/// accessed as FIFO queues.
44
44
///
45
45
/// It is useful for testing purposes, as it allows to assert that the roles have sent specific
@@ -48,8 +48,8 @@ enum SnifferError {
48
48
pub struct Sniffer {
49
49
listening_address : SocketAddr ,
50
50
upstream_address : SocketAddr ,
51
- downstream_messages : MessagesAggregator ,
52
- upstream_messages : MessagesAggregator ,
51
+ messages_from_downstream : MessagesAggregator ,
52
+ messages_from_upstream : MessagesAggregator ,
53
53
}
54
54
55
55
impl Sniffer {
@@ -59,8 +59,8 @@ impl Sniffer {
59
59
Self {
60
60
listening_address,
61
61
upstream_address,
62
- downstream_messages : MessagesAggregator :: new ( ) ,
63
- upstream_messages : MessagesAggregator :: new ( ) ,
62
+ messages_from_downstream : MessagesAggregator :: new ( ) ,
63
+ messages_from_upstream : MessagesAggregator :: new ( ) ,
64
64
}
65
65
}
66
66
@@ -80,8 +80,8 @@ impl Sniffer {
80
80
)
81
81
. await
82
82
. expect ( "Failed to create upstream" ) ;
83
- let downstream_messages = self . downstream_messages . clone ( ) ;
84
- let upstream_messages = self . upstream_messages . clone ( ) ;
83
+ let downstream_messages = self . messages_from_downstream . clone ( ) ;
84
+ let upstream_messages = self . messages_from_upstream . clone ( ) ;
85
85
let _ = select ! {
86
86
r = Self :: recv_from_down_send_to_up( downstream_receiver, upstream_sender, downstream_messages) => r,
87
87
r = Self :: recv_from_up_send_to_down( upstream_receiver, downstream_sender, upstream_messages) => r,
@@ -95,8 +95,8 @@ impl Sniffer {
95
95
/// This can be used to assert that the downstream sent:
96
96
/// - specific message types
97
97
/// - specific message fields
98
- pub fn next_downstream_message ( & self ) -> Option < ( MsgType , AnyMessage < ' static > ) > {
99
- self . downstream_messages . next_message ( )
98
+ pub fn next_message_from_downstream ( & self ) -> Option < ( MsgType , AnyMessage < ' static > ) > {
99
+ self . messages_from_downstream . next_message ( )
100
100
}
101
101
102
102
/// Returns the oldest message sent by upstream.
@@ -106,8 +106,8 @@ impl Sniffer {
106
106
/// This can be used to assert that the upstream sent:
107
107
/// - specific message types
108
108
/// - specific message fields
109
- pub fn next_upstream_message ( & self ) -> Option < ( MsgType , AnyMessage < ' static > ) > {
110
- self . upstream_messages . next_message ( )
109
+ pub fn next_message_from_upstream ( & self ) -> Option < ( MsgType , AnyMessage < ' static > ) > {
110
+ self . messages_from_upstream . next_message ( )
111
111
}
112
112
113
113
async fn create_downstream (
@@ -433,17 +433,17 @@ impl Drop for Sniffer {
433
433
std:: panic:: set_hook ( Box :: new ( |_| {
434
434
println ! ( ) ;
435
435
} ) ) ;
436
- if !self . downstream_messages . is_empty ( ) {
436
+ if !self . messages_from_downstream . is_empty ( ) {
437
437
println ! (
438
438
"You didn't handle all downstream messages: {:?}" ,
439
- self . downstream_messages
439
+ self . messages_from_downstream
440
440
) ;
441
441
panic ! ( ) ;
442
442
}
443
- if !self . upstream_messages . is_empty ( ) {
443
+ if !self . messages_from_upstream . is_empty ( ) {
444
444
println ! (
445
445
"You didn't handle all upstream messages: {:?}" ,
446
- self . upstream_messages
446
+ self . messages_from_upstream
447
447
) ;
448
448
panic ! ( ) ;
449
449
}
0 commit comments