Struct cdtoc::AccurateRip
source · pub struct AccurateRip(/* private fields */);accuraterip only.Expand description
AccurateRip ID.
This struct holds an AccurateRip ID.
Values of this type are returned by Toc::accuraterip_id.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let ar_id = toc.accuraterip_id();
// Usually you'll want this value as a string:
assert_eq!(
ar_id.to_string(),
"004-0002189a-00087f33-1f02e004",
);
// But you can also get a binary version matching the format of the
// checksum bin files:
assert_eq!(
<[u8; 13]>::from(ar_id),
[4, 154, 24, 2, 0, 51, 127, 8, 0, 4, 224, 2, 31],
);Implementations§
source§impl AccurateRip
impl AccurateRip
sourcepub const DRIVE_OFFSET_URL: &'static str = "http://www.accuraterip.com/accuraterip/DriveOffsets.bin"
pub const DRIVE_OFFSET_URL: &'static str = "http://www.accuraterip.com/accuraterip/DriveOffsets.bin"
Drive Offset Data URL.
The binary-encoded list of known AccurateRip drive offsets can be downloaded from this fixed URL.
The method AccurateRip::parse_drive_offsets can be used to parse
the raw data into a Rustful structure.
source§impl AccurateRip
impl AccurateRip
sourcepub const fn audio_len(&self) -> u8
pub const fn audio_len(&self) -> u8
Number of Audio Tracks.
Examples
use cdtoc::Toc;
// From Toc.
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
assert_eq!(toc.audio_len(), 4_usize);
// From AccurateRip.
let disc_id = toc.accuraterip_id();
assert_eq!(disc_id.audio_len(), 4_u8);sourcepub fn checksum_url(&self) -> String
pub fn checksum_url(&self) -> String
AccurateRip Checksum URL.
This returns the URL where you can download the v1 and v2 checksums for
the disc, provided it is actually in the AccurateRip database. (If it
isn’t, their server will return a 404.)
You can also get this directly via Toc::accuraterip_checksum_url.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let ar_id = toc.accuraterip_id();
assert_eq!(
ar_id.checksum_url(),
"http://www.accuraterip.com/accuraterip/a/9/8/dBAR-004-0002189a-00087f33-1f02e004.bin",
);sourcepub const fn cddb_id(&self) -> Cddb
pub const fn cddb_id(&self) -> Cddb
CDDB ID.
In cases where your application requires both AccurateRip and CDDB IDs,
using this method to obtain the latter is cheaper than calling
Toc::cddb_id.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let ar_id = toc.accuraterip_id();
assert_eq!(
ar_id.cddb_id(),
toc.cddb_id(),
);sourcepub fn decode<S>(src: S) -> Result<Self, TocError>where
S: AsRef<str>,
pub fn decode<S>(src: S) -> Result<Self, TocError>where S: AsRef<str>,
Decode.
Convert an AccurateRip ID string back into an AccurateRip instance.
Examples
use cdtoc::{AccurateRip, Toc};
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let ar_id = toc.accuraterip_id();
let ar_str = ar_id.to_string();
assert_eq!(ar_str, "004-0002189a-00087f33-1f02e004");
assert_eq!(AccurateRip::decode(ar_str), Ok(ar_id));Alternatively, you can use its FromStr and TryFrom<&str> impls:
use cdtoc::{AccurateRip, Toc};
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let ar_id = toc.accuraterip_id();
let ar_str = ar_id.to_string();
assert_eq!(AccurateRip::try_from(ar_str.as_str()), Ok(ar_id));
assert_eq!(ar_str.parse::<AccurateRip>(), Ok(ar_id));Errors
This will return an error if decoding fails.
sourcepub fn parse_checksums(
&self,
bin: &[u8]
) -> Result<Vec<BTreeMap<u32, u8>>, TocError>
pub fn parse_checksums( &self, bin: &[u8] ) -> Result<Vec<BTreeMap<u32, u8>>, TocError>
Parse Checksums.
This will parse the v1 and v2 track checksums from a raw AccurateRip checksum bin file.
The return result is a vector — indexed by track number (n-1) — of
checksum => confidence pairs.
Note: AccurateRip does not differentiate between v1 and v2 checksums; the only way to know which is which is to find a match for a checksum you calculated yourself.
Errors
This will return an error if parsing is unsuccessful, or the result is empty.
sourcepub fn parse_drive_offsets(
raw: &[u8]
) -> Result<BTreeMap<(&str, &str), i16>, TocError>
pub fn parse_drive_offsets( raw: &[u8] ) -> Result<BTreeMap<(&str, &str), i16>, TocError>
Parse Drive Offsets.
This will parse the vendor, model, and sample read offset information from the raw AccurateRip offset list (bin file).
The parsed offsets will be grouped by (vendor, model). Some entries
will not have a vendor, but entries without models are silently
ignored.
Errors
This will return an error if parsing is unsuccessful, or the result is empty.
sourcepub fn pretty_print(&self) -> String
pub fn pretty_print(&self) -> String
Pretty Print.
Return a String representation of the disc ID, same as AccurateRip::to_string,
but a little faster.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("D+96+4FFB+7F76+BB0A+EF38+12FB3+16134+1BCC4+1EC21+24A6A+272F9+299FA+2CCA6+30EE6").unwrap();
assert_eq!(
toc.accuraterip_id().pretty_print(),
"013-0015deca-00d9b921-9a0a6e0d",
);Trait Implementations§
source§impl AsRef<[u8]> for AccurateRip
impl AsRef<[u8]> for AccurateRip
source§impl Clone for AccurateRip
impl Clone for AccurateRip
source§fn clone(&self) -> AccurateRip
fn clone(&self) -> AccurateRip
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for AccurateRip
impl Debug for AccurateRip
source§impl<'de> Deserialize<'de> for AccurateRip
Available on crate feature serde only.
impl<'de> Deserialize<'de> for AccurateRip
serde only.source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl Display for AccurateRip
impl Display for AccurateRip
source§impl From<&Toc> for AccurateRip
impl From<&Toc> for AccurateRip
source§impl From<AccurateRip> for [u8; 13]
impl From<AccurateRip> for [u8; 13]
source§fn from(src: AccurateRip) -> Self
fn from(src: AccurateRip) -> Self
source§impl FromStr for AccurateRip
impl FromStr for AccurateRip
source§impl Hash for AccurateRip
impl Hash for AccurateRip
source§impl PartialEq for AccurateRip
impl PartialEq for AccurateRip
source§fn eq(&self, other: &AccurateRip) -> bool
fn eq(&self, other: &AccurateRip) -> bool
self and other values to be equal, and is used
by ==.source§impl Serialize for AccurateRip
Available on crate feature serde only.
impl Serialize for AccurateRip
serde only.