@@ -721,32 +721,33 @@ pub mod watchdog;
721
721
/// # Capture1
722
722
/// };
723
723
///
724
- /// capture.set_resolution (1.ms());
724
+ /// capture.try_set_resolution (1.ms()).unwrap( );
725
725
///
726
- /// let before = block!(capture.capture (Channel::_1)).unwrap();
727
- /// let after = block!(capture.capture (Channel::_1)).unwrap();
726
+ /// let before = block!(capture.try_capture (Channel::_1)).unwrap();
727
+ /// let after = block!(capture.try_capture (Channel::_1)).unwrap();
728
728
///
729
729
/// let period = after.wrapping_sub(before);
730
730
///
731
731
/// println!("Period: {} ms", period);
732
732
/// }
733
733
///
734
- /// # use std ::convert::Infallible;
734
+ /// # use core ::convert::Infallible;
735
735
/// # struct MilliSeconds(u32);
736
736
/// # trait U32Ext { fn ms(self) -> MilliSeconds; }
737
737
/// # impl U32Ext for u32 { fn ms(self) -> MilliSeconds { MilliSeconds(self) } }
738
738
/// # struct Capture1;
739
739
/// # enum Channel { _1 }
740
740
/// # impl hal::Capture for Capture1 {
741
+ /// # type Error = Infallible;
741
742
/// # type Capture = u16;
742
743
/// # type Channel = Channel;
743
744
/// # type Error = Infallible;
744
745
/// # type Time = MilliSeconds;
745
- /// # fn capture (&mut self, _: Channel) -> ::nb::Result<u16, Infallible > { Ok(0) }
746
- /// # fn disable (&mut self, _: Channel) { unimplemented!() }
747
- /// # fn enable (&mut self, _: Channel) { unimplemented!() }
748
- /// # fn get_resolution (&self) -> MilliSeconds { unimplemented!() }
749
- /// # fn set_resolution <T>(&mut self, _: T) where T: Into<MilliSeconds> {}
746
+ /// # fn try_capture (&mut self, _: Channel) -> ::nb::Result<u16, Self::Error > { Ok(0) }
747
+ /// # fn try_disable (&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() }
748
+ /// # fn try_enable (&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() }
749
+ /// # fn try_get_resolution (&self) -> Result< MilliSeconds, Self::Error> { unimplemented!() }
750
+ /// # fn try_set_resolution <T>(&mut self, _: T) -> Result<(), Self::Error> where T: Into<MilliSeconds> {}
750
751
/// # }
751
752
/// ```
752
753
#[ cfg( feature = "unproven" ) ]
@@ -778,19 +779,19 @@ pub trait Capture {
778
779
///
779
780
/// NOTE that you must multiply the returned value by the *resolution* of
780
781
/// this `Capture` interface to get a human time unit (e.g. seconds)
781
- fn capture ( & mut self , channel : Self :: Channel ) -> nb:: Result < Self :: Capture , Self :: Error > ;
782
+ fn try_capture ( & mut self , channel : Self :: Channel ) -> nb:: Result < Self :: Capture , Self :: Error > ;
782
783
783
784
/// Disables a capture `channel`
784
- fn disable ( & mut self , channel : Self :: Channel ) ;
785
+ fn try_disable ( & mut self , channel : Self :: Channel ) -> Result < ( ) , Self :: Error > ;
785
786
786
787
/// Enables a capture `channel`
787
- fn enable ( & mut self , channel : Self :: Channel ) ;
788
+ fn try_enable ( & mut self , channel : Self :: Channel ) -> Result < ( ) , Self :: Error > ;
788
789
789
790
/// Returns the current resolution
790
- fn get_resolution ( & self ) -> Self :: Time ;
791
+ fn try_get_resolution ( & self ) -> Result < Self :: Time , Self :: Error > ;
791
792
792
793
/// Sets the resolution of the capture timer
793
- fn set_resolution < R > ( & mut self , resolution : R )
794
+ fn try_set_resolution < R > ( & mut self , resolution : R ) -> Result < ( ) , Self :: Error >
794
795
where
795
796
R : Into < Self :: Time > ;
796
797
}
0 commit comments