[][src]Struct alphaid::AlphaId

pub struct AlphaId { /* fields omitted */ }

Used for encoding and decoding.

Methods

impl AlphaId[src]

pub fn builder() -> Builder[src]

Returns a builder type to configure a new AlphaId.

pub fn new() -> Self[src]

Creates a new AlphaId with a default configuration.

pub fn encode(&self, n: u128) -> Vec<u8>[src]

Encode the numbers.

Example

use alphaid::AlphaId;

let alphaid = AlphaId::new();
assert_eq!(alphaid.encode(0), b"a");
assert_eq!(alphaid.encode(1), b"b");
assert_eq!(alphaid.encode(1350997667), b"90F7qb");

pub fn decode<V: AsRef<[u8]>>(&self, v: V) -> Result<u128, DecodeError>[src]

Decode into numbers.

Example

use alphaid::AlphaId;

let alphaid = AlphaId::new();
assert_eq!(alphaid.decode(b"a"), Ok(0));
assert_eq!(alphaid.decode(b"b"), Ok(1));
assert_eq!(alphaid.decode(b"90F7qb"), Ok(1350997667)); 

Auto Trait Implementations

impl RefUnwindSafe for AlphaId

impl Send for AlphaId

impl Sync for AlphaId

impl Unpin for AlphaId

impl UnwindSafe for AlphaId

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.