[][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) -> Result<Self, &'static str>[src]

Create a new ID from a u32 value.

Errors

Returns Err(&'static str) if value is zero.

Examples

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

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

Create a new ID from a u32 value.

Panics

Panics if value is zero.

Examples

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

Examples

let id = ID::from_u32(42);
assert_eq!(42, u32::from(id));

Trait Implementations

impl Clone for ID[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for ID[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl AsRef<NonZeroU32> for ID[src]

impl From<NonZeroU32> for ID[src]

impl From<ID> for NonZeroU32[src]

impl From<ID> for u32[src]

impl PartialOrd<ID> for ID[src]

impl PartialOrd<u32> for ID[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialOrd<ID> for u32[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialEq<ID> for ID[src]

impl PartialEq<u32> for ID[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<ID> for u32[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl AsMut<NonZeroU32> for ID[src]

impl Copy for ID[src]

impl Eq for ID[src]

impl Display for ID[src]

impl Debug for ID[src]

impl Hash for ID[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

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!(ID::try_from(0).is_err());

impl FromStr for ID[src]

type Err = <NonZeroU32 as FromStr>::Err

The associated error which can be returned from parsing.

impl Serialize for ID[src]

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

Auto Trait Implementations

impl Sync for ID

impl Send for ID

impl Unpin for ID

impl RefUnwindSafe for ID

impl UnwindSafe for ID

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]