Beatsaber Rust Utilities: A Beatsaber V3 parsing library.
beatsaber beatmap
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at dev 58 lines 1.6 kB view raw
1//! Traits that are used to get an object's position in time and duration. 2 3/// Represents any beatmap object that happens at a specific beat. 4pub trait Timed { 5 /// Returns the beat that an object takes place. 6 fn get_beat(&self) -> f32; 7} 8 9/// Represents any beatmap object that happens over a duration of time in beats. 10pub trait Duration: Timed { 11 /// Returns the beat that an object ends. 12 fn get_end_beat(&self) -> f32; 13 /// Returns the length (in beats) that an object takes place. 14 fn get_duration(&self) -> f32; 15} 16 17#[macro_export] 18#[doc(hidden)] 19macro_rules! impl_timed { 20 ($ident:ident::$beat:ident) => { 21 impl crate::timing_traits::Timed for $ident { 22 fn get_beat(&self) -> f32 { 23 self.$beat 24 } 25 } 26 }; 27} 28 29#[macro_export] 30#[doc(hidden)] 31macro_rules! impl_duration { 32 ($ident:ident::$beat:ident, end: $end:ident) => { 33 impl_timed!($ident::$beat); 34 35 impl crate::timing_traits::Duration for $ident { 36 fn get_end_beat(&self) -> f32 { 37 self.$end 38 } 39 40 fn get_duration(&self) -> f32 { 41 self.$end - self.$beat 42 } 43 } 44 }; 45 ($ident:ident::$beat:ident, duration: $duration:ident) => { 46 impl_timed!($ident::$beat); 47 48 impl crate::timing_traits::Duration for $ident { 49 fn get_end_beat(&self) -> f32 { 50 self.$beat + self.$duration 51 } 52 53 fn get_duration(&self) -> f32 { 54 self.$duration 55 } 56 } 57 }; 58}