Struct isbn2::Isbn13[][src]

pub struct Isbn13 { /* fields omitted */ }

13-digit ISBN format.

Implementations

impl Isbn13[src]

pub fn new(digits: [u8; 13]) -> IsbnResult<Isbn13>[src]

Creates a new ISBN13 code from 13 digits. Verifies that the checksum is correct, and that no digits are out of bounds.

Examples

use isbn2::Isbn13;

let isbn13 = Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap();

Errors

If any of the digits exceed nine, an error will be returned. If the check digit is not correct for the ISBN, an error will also be returned.

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

Hyphenate an ISBN-13 into its parts:

  • GS1 Prefix
  • Registration group
  • Registrant
  • Publication
  • Check digit
use isbn2::Isbn13;

let isbn_13 = Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap();
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::Isbn13;

let isbn_13 = Isbn13::new([9, 7, 8, 1, 4, 9, 2, 0, 6, 7, 6, 6, 5]).unwrap();
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 Isbn13[src]

impl Copy for Isbn13[src]

impl Debug for Isbn13[src]

impl Display for Isbn13[src]

impl Eq for Isbn13[src]

impl From<Isbn10> for Isbn13[src]

impl From<Isbn13> for Isbn[src]

impl FromStr for Isbn13[src]

type Err = IsbnError

The associated error which can be returned from parsing.

impl Hash for Isbn13[src]

impl PartialEq<Isbn13> for Isbn13[src]

impl StructuralEq for Isbn13[src]

impl StructuralPartialEq for Isbn13[src]

Auto Trait Implementations

impl Send for Isbn13

impl Sync for Isbn13

impl Unpin for Isbn13

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.