[][src]Struct ichen_openprotocol::ID

pub struct ID(_);

A 32-bit numeric ID that cannot be zero or negative.

This type is usually used for specifying a unique identification number.

Methods

impl ID[src]

pub fn new(value: u32) -> Option<Self>[src]

Create a new ID from a u32 value.

Errors

Returns None if value is zero.

Examples

let id = ID::new(42).unwrap();
assert_eq!(42, u32::from(id));
assert_eq!(None, ID::new(0));

pub fn from_u32(value: u32) -> Self[src]

Create a new ID from a u32 value.

Panics

Panics if value is zero.

Error Examples

let id = ID::from_u32(0);    // This will panic.

Examples

let id = ID::from_u32(42);
assert_eq!(42, id.get());

pub fn get(self) -> u32[src]

Convert an ID into a u32 value.

Examples

let id = ID::new(42).unwrap();
assert_eq!(42, id.get());

Methods from Deref<Target = NonZeroU32>

Trait Implementations

impl AsMut<NonZeroU32> for ID[src]

impl AsRef<NonZeroU32> for ID[src]

impl Clone for ID[src]

impl Copy for ID[src]

impl Debug for ID[src]

impl Deref for ID[src]

type Target = NonZeroU32

The resulting type after dereferencing.

impl DerefMut for ID[src]

impl<'de> Deserialize<'de> for ID[src]

impl Display for ID[src]

impl Eq for ID[src]

impl From<ID> for NonZeroU32[src]

impl From<ID> for u32[src]

impl From<NonZeroU32> for ID[src]

impl FromStr for ID[src]

type Err = <NonZeroU32 as FromStr>::Err

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 PartialEq<ID> for u32[src]

impl PartialEq<u32> for ID[src]

impl PartialOrd<ID> for ID[src]

impl PartialOrd<ID> for u32[src]

impl PartialOrd<u32> for ID[src]

impl Serialize for ID[src]

impl StructuralEq for ID[src]

impl StructuralPartialEq for ID[src]

impl TryFrom<u32> for ID[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: u32) -> Result<Self, Self::Error>[src]

Create a new ID from an integer value;

Errors

Return Err(&'static str) if num is zero.

Examples

let id = ID::try_from(42).unwrap();
assert_eq!(42, u32::from(id));
assert_eq!(Err("ID value cannot be zero."), ID::try_from(0));

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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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<T> Typeable for T where
    T: Any