[][src]Struct uhlc::ID

pub struct ID { /* fields omitted */ }

An identifier for an HLC (MAX_SIZE bytes maximum). This struct has a constant memory size (holding internally a [u8; MAX_SIZE] + a usize), allowing allocations on the stack for better performances.

Examples

use uhlc::ID;

let buf = [0x1a, 0x2b, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
let id = ID::new(3, buf);
assert_eq!(id.size(), 3);
assert_eq!(id.as_slice(), &[0x1a, 0x2b, 0x3c]);
assert_eq!(id.to_string(), "1A2B3C".to_string());
use uhlc::ID;
use uuid::Uuid;

let id = ID::from(Uuid::new_v4());
assert_eq!(id.size(), 16);

Implementations

impl ID[src]

pub const MAX_SIZE: usize[src]

The maximum size of an ID in bytes: 16.

pub fn new(size: usize, id: [u8; 16]) -> ID[src]

Create a new ID with the "size" first bytes of "id"

pub fn size(&self) -> usize[src]

The size of this ID in bytes

pub fn as_slice(&self) -> &[u8][src]

This ID as a slice

Trait Implementations

impl Clone for ID[src]

impl Debug for ID[src]

impl Display for ID[src]

impl Eq for ID[src]

impl From<Uuid> for ID[src]

impl FromStr for ID[src]

type Err = ParseIDError

The associated error which can be returned from parsing.

impl Hash for ID[src]

impl Ord for ID[src]

impl PartialEq<ID> for ID[src]

impl PartialOrd<ID> for ID[src]

impl StructuralEq for ID[src]

impl<'_> TryFrom<&'_ [u8]> for ID[src]

type Error = String

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for ID

impl Send for ID

impl Sync for ID

impl Unpin for ID

impl UnwindSafe for ID

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,