[−][src]Struct alphaid::AlphaId
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]
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,
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.
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>,