added rust documentation comments

This commit is contained in:
Simon Wörner
2017-07-10 15:20:14 +02:00
parent 088867352c
commit fe8806a4d5
12 changed files with 100 additions and 10 deletions

View File

@@ -3,6 +3,10 @@ name = "emergency_stop"
version = "0.1.0"
authors = ["Simon Wörner <git@simon-woerner.de>"]
[[bin]]
name = "emergency_stop-test"
doc = false
[features]
measure = ["kawaii/measure"]

View File

@@ -18,6 +18,10 @@ pub struct EmergencyStop {
}
impl EmergencyStop {
/// Constructs a new `EmergencyStop` and starts poll thread.
///
/// # Parameter
/// - `stop_port` GPIO Port number of emergency stop pin.
pub fn new(stop_port: u8) -> std::io::Result<Self> {
let name = format!("EmergencyStop(port = {})", stop_port);
let state = Arc::new(AtomicBool::new(false));
@@ -29,11 +33,12 @@ impl EmergencyStop {
.spawn(move || EmergencyStop::thread(&mut port, state_clone))?;
Ok(EmergencyStop {
thread: Some(thread),
state: state,
})
thread: Some(thread),
state: state,
})
}
/// Emergency stop poll thread
fn thread(port: &mut AsyncPort, state: Arc<AtomicBool>) {
#[cfg(feature = "measure")]
let mut measure = Measure::new(format!("EmergencyStop(port = {})", port.port.number));
@@ -86,6 +91,7 @@ impl EmergencyStop {
}
impl Drop for EmergencyStop {
/// Set emergency stop and join poll thread.
fn drop(&mut self) {
self.state.store(true, Ordering::Relaxed);