@@ -108,27 +108,31 @@ impl Pin {
108108 }
109109}
110110
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 )
114116 }
115117
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 )
118120 }
119121}
120122
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 )
125129 } else {
126- self . 0 . get_value ( ) . unwrap ( ) == 0
130+ self . 0 . get_value ( ) . map ( |val| val == 0 )
127131 }
128132 }
129133
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 )
132136 }
133137}
134138
0 commit comments