How do I convert Duration to u64

I am writing a project and i need to convert a Duration type to u64, how do i do this.

my attempt so far

let mut song_duration = mp3_duration::from_path(&active_dir).unwrap()
let mut duration_64 = u64::from(song_duration);

u64 in what unit? Integer years? Picoseconds? Samples?

5 Likes

How about Duration::as_secs?

3 Likes

seconds

Then @jofas is correct.

let song_duration = mp3_duration::from_path(&active_dir).unwrap();
let duration_64 = song_duration.as_secs();

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.