This repository was archived by the owner on Dec 15, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-9
lines changed Expand file tree Collapse file tree 2 files changed +32
-9
lines changed Original file line number Diff line number Diff line change 1
1
#![ deny( warnings) ]
2
- #![ feature( conservative_impl_trait) ]
3
2
4
3
extern crate chrono;
5
4
extern crate clap;
@@ -103,9 +102,9 @@ fn run() -> Result<()> {
103
102
let p = decoder. read_packet ( ) ;
104
103
match p {
105
104
Ok ( p) => {
106
- match p. kind {
107
- packet:: Kind :: Instrumentation ( ref ud ) if ud . port == port => {
108
- stdout. write_all ( & ud . payload ) ?;
105
+ match p. kind ( ) {
106
+ & packet:: Kind :: Instrumentation ( ref i ) if i . port ( ) == port => {
107
+ stdout. write_all ( & i . payload ( ) ) ?;
109
108
}
110
109
_ => ( ) ,
111
110
}
@@ -139,7 +138,7 @@ fn run() -> Result<()> {
139
138
// Unreachable.
140
139
}
141
140
142
- fn open_read < ' a > ( matches : & ArgMatches ) -> Result < impl io:: Read + ' a > {
141
+ fn open_read ( matches : & ArgMatches ) -> Result < Box < io:: Read + ' static > > {
143
142
let path = matches. value_of ( "file" ) ;
144
143
Ok ( match path {
145
144
Some ( path) => {
Original file line number Diff line number Diff line change @@ -9,10 +9,22 @@ pub const MAX_PAYLOAD_SIZE: usize = 4;
9
9
#[ derive( Debug ) ]
10
10
pub struct Packet {
11
11
/// The header byte received for this packet.
12
- pub header : u8 ,
12
+ pub ( crate ) header : u8 ,
13
13
14
14
/// The kind (type) of this packet.
15
- pub kind : Kind ,
15
+ pub ( crate ) kind : Kind ,
16
+ }
17
+
18
+ impl Packet {
19
+ /// Returns the header byte received for this packet.
20
+ pub fn header ( & self ) -> u8 {
21
+ self . header
22
+ }
23
+
24
+ /// The kind (type) of this packet.
25
+ pub fn kind ( & self ) -> & Kind {
26
+ & self . kind
27
+ }
16
28
}
17
29
18
30
/// The type of a packet.
@@ -30,10 +42,22 @@ pub enum Kind {
30
42
/// Contents of an Instrumentation packet, with data from a software application
31
43
pub struct Instrumentation {
32
44
/// Data in this packet.
33
- pub payload : HVec < u8 , [ u8 ; MAX_PAYLOAD_SIZE ] > ,
45
+ pub ( crate ) payload : HVec < u8 , [ u8 ; MAX_PAYLOAD_SIZE ] > ,
34
46
35
47
/// Stimulus port this packet was sent from.
36
- pub port : u8 ,
48
+ pub ( crate ) port : u8 ,
49
+ }
50
+
51
+ impl Instrumentation {
52
+ /// Data in this packet.
53
+ pub fn payload ( & self ) -> & [ u8 ] {
54
+ & * self . payload
55
+ }
56
+
57
+ /// Stimulus port this packet was sent from.
58
+ pub fn port ( & self ) -> u8 {
59
+ self . port
60
+ }
37
61
}
38
62
39
63
impl Debug for Instrumentation {
You can’t perform that action at this time.
0 commit comments