Enum isbn2::Isbn[][src]

pub enum Isbn {
    _10(Isbn10),
    _13(Isbn13),
}

An International Standard Book Number, either ISBN10 or ISBN13.

Examples

use isbn2::{Isbn, Isbn10, Isbn13};

let isbn_10 = Isbn::_10(Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap());
let isbn_13 = Isbn::_13(Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap());

assert_eq!("89-6626-126-4".parse(), Ok(isbn_10));
assert_eq!("978-1-4920-6766-5".parse(), Ok(isbn_13));

Variants

_10(Isbn10)
_13(Isbn13)

Implementations

impl Isbn[src]

pub fn hyphenate(&self) -> Result<ArrayString<[u8; 17]>, IsbnError>[src]

Hyphenate an ISBN into its parts:

  • GS1 Prefix (ISBN-13 only)
  • Registration group
  • Registrant
  • Publication
  • Check digit
use isbn2::{Isbn, Isbn10, Isbn13};

let isbn_10 = Isbn::_10(Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap());
let isbn_13 = Isbn::_13(Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap());

assert_eq!(isbn_10.hyphenate().unwrap().as_str(), "89-6626-126-4");
assert_eq!(isbn_13.hyphenate().unwrap().as_str(), "978-1-4920-6766-5");

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::{Isbn, Isbn10, Isbn13};

let isbn_10 = Isbn::_10(Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap());
let isbn_13 = Isbn::_13(Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap());

assert_eq!(isbn_10.registration_group(), Ok("Korea, Republic"));
assert_eq!(isbn_13.registration_group(), Ok("English language"));

Errors

If the ISBN is not valid, as determined by the current ISBN rules, an error will be returned.

Trait Implementations

impl Clone for Isbn[src]

impl Debug for Isbn[src]

impl Display for Isbn[src]

impl Eq for Isbn[src]

impl From<Isbn10> for Isbn[src]

impl From<Isbn13> for Isbn[src]

impl FromStr for Isbn[src]

type Err = IsbnError

The associated error which can be returned from parsing.

impl PartialEq<Isbn> for Isbn[src]

impl StructuralEq for Isbn[src]

impl StructuralPartialEq for Isbn[src]

Auto Trait Implementations

impl Send for Isbn

impl Sync for Isbn

impl Unpin for Isbn

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.