pub struct Cddb(/* private fields */);Available on crate feature
cddb only.Expand description
CDDB ID.
This struct holds a CDDB ID.
Values of this type are returned by Toc::cddb_id.
Examples
use cdtoc::Toc;
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let cddb_id = toc.cddb_id();
// Usually you'll want this value as a string:
assert_eq!(
cddb_id.to_string(),
"1f02e004",
);
// But you can also get it as a `u32`:
assert_eq!(
u32::from(cddb_id),
520_282_116,
);Implementations§
source§impl Cddb
impl Cddb
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 a CDDB ID string back into a Cddb instance.
Examples
use cdtoc::{Cddb, Toc};
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let cddb_id = toc.cddb_id();
let cddb_str = cddb_id.to_string();
assert_eq!(cddb_str, "1f02e004");
assert_eq!(Cddb::decode(cddb_str), Ok(cddb_id));Alternatively, you can use its FromStr and TryFrom<&str> impls:
use cdtoc::{Cddb, Toc};
let toc = Toc::from_cdtoc("4+96+2D2B+6256+B327+D84A").unwrap();
let cddb_id = toc.cddb_id();
let cddb_str = cddb_id.to_string();
assert_eq!(Cddb::try_from(cddb_str.as_str()), Ok(cddb_id));
assert_eq!(cddb_str.parse::<Cddb>(), Ok(cddb_id));Errors
This will return an error if decoding fails.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Cddb
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Cddb
Available on crate feature
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Cddb
impl PartialEq for Cddb
impl Copy for Cddb
impl Eq for Cddb
Auto Trait Implementations§
impl RefUnwindSafe for Cddb
impl Send for Cddb
impl Sync for Cddb
impl Unpin for Cddb
impl UnwindSafe for Cddb
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