[−][src]Struct alphaid::AlphaId
Used for encoding and decoding.
Implementations
impl<T: UnsignedInteger> AlphaId<T>
[src]
pub fn builder() -> Builder<T>
[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: T) -> Result<Vec<u8>, AlphaIdError>
[src]
Encode the numbers.
Example
use alphaid::AlphaId; let alphaid = AlphaId::<u32>::new(); assert_eq!(alphaid.encode(0), Ok(b"a".to_vec())); assert_eq!(alphaid.encode(1), Ok(b"b".to_vec())); assert_eq!(alphaid.encode(1350997667), Ok(b"90F7qb".to_vec()));
pub fn decode<V: AsRef<[u8]>>(&self, v: V) -> Result<T, AlphaIdError>
[src]
Decode into numbers.
Example
use alphaid::AlphaId; let alphaid = AlphaId::<u32>::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<T> RefUnwindSafe for AlphaId<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for AlphaId<T> where
T: Send,
T: Send,
impl<T> Sync for AlphaId<T> where
T: Sync,
T: Sync,
impl<T> Unpin for AlphaId<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for AlphaId<T> where
T: UnwindSafe,
T: UnwindSafe,
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>,