pub struct Isbn10 { /* private fields */ }Expand description
10-digit ISBN format.
Implementations§
Source§impl Isbn10
impl Isbn10
Sourcepub fn new(digits: [u8; 10]) -> IsbnResult<Isbn10>
pub fn new(digits: [u8; 10]) -> IsbnResult<Isbn10>
Creates a new ISBN10 code from 10 digits. Verifies that the checksum is correct, and that no digits are out of bounds.
§Examples
use isbn::Isbn10;
let isbn10 = Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap();§Errors
If any of the first nine digits exceed nine, or the tenth digit exceeds 10, an error will be returned. If the check digit is not correct for the ISBN, an error will also be returned.
Sourcepub fn try_from(isbn13: Isbn13) -> IsbnResult<Self>
pub fn try_from(isbn13: Isbn13) -> IsbnResult<Self>
Convert ISBN-13 to ISBN-10, if applicable.
use isbn::{Isbn10, Isbn13};
let isbn_13 = Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap();
assert_eq!(Isbn10::try_from(isbn_13), "1-4920-6766-0".parse());§Errors
If the ISBN13 does not have a 978 prefix, it can not be downcast to an ISBN10, and an error will be returned.
Sourcepub fn hyphenate(&self) -> Result<ArrayString<17>, IsbnError>
pub fn hyphenate(&self) -> Result<ArrayString<17>, IsbnError>
Hyphenate an ISBN-10 into its parts:
- Registration group
- Registrant
- Publication
- Check digit
use isbn::Isbn10;
let isbn_10 = Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap();
assert_eq!(isbn_10.hyphenate().unwrap().as_str(), "89-6626-126-4");§Errors
If the ISBN is not valid, as determined by the current ISBN rules, an error will be returned.
Sourcepub fn registration_group(&self) -> Result<&str, IsbnError>
pub fn registration_group(&self) -> Result<&str, IsbnError>
Retrieve the name of the registration group.
use isbn::Isbn10;
let isbn_10 = Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap();
assert_eq!(isbn_10.registration_group(), Ok("Korea, Republic"));§Errors
If the ISBN is not valid, as determined by the current ISBN rules, an error will be returned.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Isbn10
impl<'de> Deserialize<'de> for Isbn10
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
impl Copy for Isbn10
impl Eq for Isbn10
impl StructuralPartialEq for Isbn10
Auto Trait Implementations§
impl Freeze for Isbn10
impl RefUnwindSafe for Isbn10
impl Send for Isbn10
impl Sync for Isbn10
impl Unpin for Isbn10
impl UnwindSafe for Isbn10
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.