pub struct Time { /* private fields */ }Expand description
Time representation of the format mm:ss:ff.
Where mm = minutes, ss = seconds, ff = frames/sectors. There are 75 frames per second, 60 seconds per minute.
Implementations§
Source§impl Time
impl Time
Sourcepub fn new(minutes: i32, seconds: i8, frames: i8) -> Time
pub fn new(minutes: i32, seconds: i8, frames: i8) -> Time
Create a new instance with the specified components.
Sourcepub fn to_string_2(&self) -> String
pub fn to_string_2(&self) -> String
Format as `mm:ss’ dropping truncating the remainding frames.
Examples found in repository?
examples/to_mb.rs (line 42)
34fn perform_conversion(source: &str) -> Result<(), Error> {
35 let mut tracklist = Tracklist::parse(source)?;
36 // TODO support multi-cds
37 assert_eq!(tracklist.files.len(), 1);
38
39 let file = tracklist.files.remove(0);
40 for ref t in file.tracks {
41 let duration = match t.duration.clone() {
42 Some(time) => time.to_string_2(),
43 None => "??:??".to_string(),
44 };
45 println!(
46 "{:02} {} - {} {}",
47 t.number,
48 t.title.as_ref().unwrap(),
49 t.performer
50 .clone()
51 .ok_or_else(|| Error::from("Not all tracks have a specified performer."))?,
52 duration
53 );
54 }
55
56 Ok(())
57}Sourcepub fn minutes(&self) -> i32
pub fn minutes(&self) -> i32
Returns the “minutes” component of this instance.
use cue_sheet::parser::Time;
let time = Time::new(1, 2, 3);
assert_eq!(time.minutes(), 1);Sourcepub fn seconds(&self) -> i8
pub fn seconds(&self) -> i8
Returns the “seconds” component of this instance.
use cue_sheet::parser::Time;
let time = Time::new(1, 2, 3);
assert_eq!(time.seconds(), 2);Sourcepub fn frames(&self) -> i8
pub fn frames(&self) -> i8
Returns the “frames/sectors” component of this instance.
use cue_sheet::parser::Time;
let time = Time::new(1, 2, 3);
assert_eq!(time.frames(), 3);Sourcepub fn total_minutes(&self) -> f64
pub fn total_minutes(&self) -> f64
Returns the total number of minutes represented by this instance.
use cue_sheet::parser::Time;
let time = Time::new(1, 2, 3);
assert_eq!(time.total_minutes(), 1.034);
let time = Time::new(2, 30, 0);
assert_eq!(time.total_minutes(), 2.5);Sourcepub fn total_seconds(&self) -> f64
pub fn total_seconds(&self) -> f64
Returns the total number of seconds represented by this instance.
use cue_sheet::parser::Time;
let time = Time::new(1, 2, 3);
assert_eq!(time.total_seconds(), 62.04);
let time = Time::new(2, 30, 0);
assert_eq!(time.total_seconds(), 150.);Sourcepub fn total_frames(&self) -> i64
pub fn total_frames(&self) -> i64
Returns the total number of frames/sectors represented by this instance.
use cue_sheet::parser::Time;
let time = Time::new(1, 2, 3);
assert_eq!(time.total_frames(), 4653);
let time = Time::new(2, 30, 5);
assert_eq!(time.total_frames(), 11255);Sourcepub fn from_frames(from: i64) -> Time
pub fn from_frames(from: i64) -> Time
Create an instance for the specified number of frames/sectors.
use cue_sheet::parser::Time;
let time = Time::from_frames(200);
assert_eq!(time, Time::new(0, 2, 50));Trait Implementations§
Source§impl Ord for Time
impl Ord for Time
Source§impl PartialOrd for Time
impl PartialOrd for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more