@@ -108,27 +108,31 @@ impl Pin {
108
108
}
109
109
}
110
110
111
- impl hal:: digital:: OutputPin for Pin {
112
- fn set_low ( & mut self ) {
113
- self . 0 . set_value ( 0 ) . unwrap ( )
111
+ impl hal:: digital:: v2:: OutputPin for Pin {
112
+ type Error = sysfs_gpio:: Error ;
113
+
114
+ fn set_low ( & mut self ) -> Result < ( ) , Self :: Error > {
115
+ self . 0 . set_value ( 0 )
114
116
}
115
117
116
- fn set_high ( & mut self ) {
117
- self . 0 . set_value ( 1 ) . unwrap ( )
118
+ fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
119
+ self . 0 . set_value ( 1 )
118
120
}
119
121
}
120
122
121
- impl hal:: digital:: InputPin for Pin {
122
- fn is_high ( & self ) -> bool {
123
- if !self . 0 . get_active_low ( ) . unwrap ( ) {
124
- self . 0 . get_value ( ) . unwrap ( ) != 0
123
+ impl hal:: digital:: v2:: InputPin for Pin {
124
+ type Error = sysfs_gpio:: Error ;
125
+
126
+ fn is_high ( & self ) -> Result < bool , Self :: Error > {
127
+ if !self . 0 . get_active_low ( ) ? {
128
+ self . 0 . get_value ( ) . map ( |val| val != 0 )
125
129
} else {
126
- self . 0 . get_value ( ) . unwrap ( ) == 0
130
+ self . 0 . get_value ( ) . map ( |val| val == 0 )
127
131
}
128
132
}
129
133
130
- fn is_low ( & self ) -> bool {
131
- ! self . is_high ( )
134
+ fn is_low ( & self ) -> Result < bool , Self :: Error > {
135
+ self . is_high ( ) . map ( |val| !val )
132
136
}
133
137
}
134
138
0 commit comments