equal
deleted
inserted
replaced
1 use std::{collections::BinaryHeap, num::NonZeroU16}; |
1 use fpnum::{fp, FPNum}; |
|
2 use std::{collections::BinaryHeap, num::NonZeroU16, ops::Add}; |
2 |
3 |
3 pub type GearId = NonZeroU16; |
4 pub type GearId = NonZeroU16; |
4 pub trait GearData {} |
5 pub trait GearData {} |
|
6 |
|
7 #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)] |
|
8 pub struct Millis(u32); |
|
9 |
|
10 impl Millis { |
|
11 #[inline] |
|
12 pub fn new(value: u32) -> Self { |
|
13 Self(value) |
|
14 } |
|
15 |
|
16 #[inline] |
|
17 pub fn get(self) -> u32 { |
|
18 self.0 |
|
19 } |
|
20 |
|
21 #[inline] |
|
22 pub fn to_fixed(self) -> FPNum { |
|
23 FPNum::new(self.0 as i32, 1000) |
|
24 } |
|
25 } |
|
26 |
|
27 impl Add for Millis { |
|
28 type Output = Self; |
|
29 |
|
30 fn add(self, rhs: Self) -> Self::Output { |
|
31 Self(self.0 + rhs.0) |
|
32 } |
|
33 } |
5 |
34 |
6 pub trait GearDataProcessor<T: GearData> { |
35 pub trait GearDataProcessor<T: GearData> { |
7 fn add(&mut self, gear_id: GearId, gear_data: T); |
36 fn add(&mut self, gear_id: GearId, gear_data: T); |
8 fn remove(&mut self, gear_id: GearId); |
37 fn remove(&mut self, gear_id: GearId); |
9 } |
38 } |