zerodds_corba_rt/
current.rs1use crate::priority::Priority;
8
9#[derive(Debug, Clone, Copy)]
13pub struct RtCurrent {
14 priority: Priority,
15}
16
17impl RtCurrent {
18 #[must_use]
20 pub fn new(priority: Priority) -> Self {
21 Self { priority }
22 }
23
24 #[must_use]
26 pub fn get_priority(&self) -> Priority {
27 self.priority
28 }
29
30 pub fn set_priority(&mut self, priority: Priority) {
32 self.priority = priority;
33 }
34}
35
36impl Default for RtCurrent {
37 fn default() -> Self {
38 Self {
40 priority: Priority::new(0).unwrap_or_else(|| Priority::clamped(0)),
41 }
42 }
43}
44
45#[cfg(test)]
46#[allow(clippy::unwrap_used, clippy::panic)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn get_set_priority() {
52 let mut cur = RtCurrent::new(Priority::new(10).unwrap());
53 assert_eq!(cur.get_priority().value(), 10);
54 cur.set_priority(Priority::new(50).unwrap());
55 assert_eq!(cur.get_priority().value(), 50);
56 }
57
58 #[test]
59 fn default_is_zero() {
60 assert_eq!(RtCurrent::default().get_priority().value(), 0);
61 }
62}