Struct isbn2::Isbn10 [−][src]
10-digit ISBN format.
Implementations
impl Isbn10
[src]
pub fn new(digits: [u8; 10]) -> IsbnResult<Isbn10>
[src]
Creates a new ISBN10 code from 10 digits. Verifies that the checksum is correct, and that no digits are out of bounds.
Examples
use isbn2::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.
pub fn try_from(isbn13: Isbn13) -> IsbnResult<Self>
[src]
Convert ISBN-13 to ISBN-10, if applicable.
use isbn2::{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.
pub fn hyphenate(&self) -> Result<ArrayString<[u8; 17]>, IsbnError>
[src]
Hyphenate an ISBN-10 into its parts:
- Registration group
- Registrant
- Publication
- Check digit
use isbn2::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.
pub fn registration_group(&self) -> Result<&str, IsbnError>
[src]
Retrieve the name of the registration group.
use isbn2::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
impl Clone for Isbn10
[src]
fn clone(&self) -> Isbn10
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Isbn10
[src]
impl Debug for Isbn10
[src]
impl Display for Isbn10
[src]
impl Eq for Isbn10
[src]
impl From<Isbn10> for Isbn
[src]
impl From<Isbn10> for Isbn13
[src]
impl FromStr for Isbn10
[src]
type Err = IsbnError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Isbn10, IsbnError>
[src]
impl Hash for Isbn10
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Isbn10> for Isbn10
[src]
impl StructuralEq for Isbn10
[src]
impl StructuralPartialEq for Isbn10
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,