From 30bea9c24b19e77301875c08c6f5267ba2a9a199 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Mon, 26 Jul 2021 15:15:00 -0400 Subject: [PATCH] Move FileProperties to types --- src/components/mod.rs | 62 +---------------------------------------- src/types/mod.rs | 1 + src/types/properties.rs | 59 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 61 deletions(-) create mode 100644 src/types/properties.rs diff --git a/src/components/mod.rs b/src/components/mod.rs index 657ca2ef..789319f3 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,62 +1,2 @@ pub(crate) mod logic; -pub(crate) mod tags; - -use std::time::Duration; - -/// Various *immutable* audio properties -/// -/// NOTE: All fields are invalidated after any type of conversion -pub struct FileProperties { - duration: Duration, - bitrate: Option, - sample_rate: Option, - channels: Option, -} - -impl Default for FileProperties { - fn default() -> Self { - Self { - duration: Duration::ZERO, - bitrate: None, - sample_rate: None, - channels: None, - } - } -} - -impl FileProperties { - /// Create a new FileProperties - pub const fn new( - duration: Duration, - bitrate: Option, - sample_rate: Option, - channels: Option, - ) -> Self { - Self { - duration, - bitrate, - sample_rate, - channels, - } - } - - /// Duration - pub fn duration(&self) -> Duration { - self.duration - } - - /// Bitrate (kbps) - pub fn bitrate(&self) -> Option { - self.bitrate - } - - /// Sample rate (Hz) - pub fn sample_rate(&self) -> Option { - self.sample_rate - } - - /// Channel count - pub fn channels(&self) -> Option { - self.channels - } -} +pub(crate) mod tags; \ No newline at end of file diff --git a/src/types/mod.rs b/src/types/mod.rs index e7e6852f..b0efb735 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,3 +1,4 @@ pub(crate) mod album; pub(crate) mod anytag; pub(crate) mod picture; +pub(crate) mod properties; diff --git a/src/types/properties.rs b/src/types/properties.rs new file mode 100644 index 00000000..b4b830f1 --- /dev/null +++ b/src/types/properties.rs @@ -0,0 +1,59 @@ +use std::time::Duration; + +/// Various *immutable* audio properties +/// +/// NOTE: All fields are invalidated after any type of conversion +pub struct FileProperties { + duration: Duration, + bitrate: Option, + sample_rate: Option, + channels: Option, +} + +impl Default for FileProperties { + fn default() -> Self { + Self { + duration: Duration::ZERO, + bitrate: None, + sample_rate: None, + channels: None, + } + } +} + +impl FileProperties { + /// Create a new FileProperties + pub const fn new( + duration: Duration, + bitrate: Option, + sample_rate: Option, + channels: Option, + ) -> Self { + Self { + duration, + bitrate, + sample_rate, + channels, + } + } + + /// Duration + pub fn duration(&self) -> Duration { + self.duration + } + + /// Bitrate (kbps) + pub fn bitrate(&self) -> Option { + self.bitrate + } + + /// Sample rate (Hz) + pub fn sample_rate(&self) -> Option { + self.sample_rate + } + + /// Channel count + pub fn channels(&self) -> Option { + self.channels + } +} \ No newline at end of file