diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-07-06 18:39:07 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-07-06 18:39:07 +0200 |
commit | f49e17fc5d44975fd37c2fd80476e3db0540479f (patch) | |
tree | ef868fbb9ecb234fe766128b9ef566a6bc7bd7d9 | |
parent | 81b94329a275bb92066404bd3bb2822c5bb3f424 (diff) | |
download | nihav-f49e17fc5d44975fd37c2fd80476e3db0540479f.tar.gz |
core/format: use common format parsing error
-rw-r--r-- | nihav-core/src/formats.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/nihav-core/src/formats.rs b/nihav-core/src/formats.rs index 4c577cf..fc8e354 100644 --- a/nihav-core/src/formats.rs +++ b/nihav-core/src/formats.rs @@ -7,6 +7,10 @@ use std::str::FromStr; use std::string::*; use std::fmt; +/// Generic format parsing error. +#[derive(Clone,Copy,Debug,PartialEq)] +pub struct FormatParseError {} + /// Audio format definition. /// /// The structure describes how audio samples are stored and what characteristics they have. @@ -114,12 +118,8 @@ impl fmt::Display for NASoniton { } } -/// Generic soniton parsing error. -#[derive(Clone,Copy,Debug,PartialEq)] -pub struct SonitonParseError {} - impl FromStr for NASoniton { - type Err = SonitonParseError; + type Err = FormatParseError; fn from_str(s: &str) -> Result<Self, Self::Err> { match s { @@ -132,7 +132,7 @@ impl FromStr for NASoniton { "s32le" => Ok(NASoniton { bits: 32, be: false, packed: false, planar: false, float: false, signed: true }), "f32be" => Ok(NASoniton { bits: 32, be: true, packed: false, planar: false, float: true, signed: true }), "f32le" => Ok(NASoniton { bits: 32, be: false, packed: false, planar: false, float: true, signed: true }), - _ => Err(SonitonParseError{}), + _ => Err(FormatParseError{}), } } } @@ -178,12 +178,8 @@ impl NAChannelType { } } -/// Generic channel configuration parsing error. -#[derive(Clone,Copy,Debug,PartialEq)] -pub struct ChannelParseError {} - impl FromStr for NAChannelType { - type Err = ChannelParseError; + type Err = FormatParseError; fn from_str(s: &str) -> Result<Self, Self::Err> { match s { @@ -215,7 +211,7 @@ impl FromStr for NAChannelType { "Rt" => Ok(NAChannelType::Rt), "Lo" => Ok(NAChannelType::Lo), "Ro" => Ok(NAChannelType::Ro), - _ => Err(ChannelParseError{}), + _ => Err(FormatParseError{}), } } } @@ -329,7 +325,7 @@ impl fmt::Display for NAChannelMap { } impl FromStr for NAChannelMap { - type Err = ChannelParseError; + type Err = FormatParseError; fn from_str(s: &str) -> Result<Self, Self::Err> { let mut chm = NAChannelMap::new(); |