Skip to main content

URID

Struct URID 

Source
pub struct URID<T = ()>(/* private fields */)
where
    T: ?Sized;
Expand description

Representation of a URI for fast comparisons.

A URID is basically a number which represents a URI, which makes the identification of other features faster and easier. The mapping of URIs to URIDs is handled by a something that implements the Map trait. A given URID can also be converted back to a URI with an implementation of the Unmap trait. However, these implementations should obviously be linked.

This struct has an optional type parameter T which defaults to (). In this case, the type can represent any URID at all, but if T is a UriBound, the instance of URID<T> can only describe the URID of the given bound. This makes creation easier and also turns it into an atomic URIDCollection, which can be used to build bigger collections.

Implementations§

Source§

impl URID

Source

pub fn new(raw_urid: u32) -> Option<URID>

Creates a new URID from a raw number.

URIDs may never be zero. If the given number is zero, None is returned.

Source§

impl<T> URID<T>
where T: ?Sized,

Source

pub unsafe fn new_unchecked(raw_urid: u32) -> URID<T>

Create a URID without checking for type or value validity.

This value may only be a URID the mapper actually produced and that is recognised by a compatible unmapper. Therefore, it should only be used by Map::map_uri or Map::map_type.

§Safety

A URID may not be 0 since this value is reserved for the None value of Option<URID<T>>, which therefore has the same size as a URID<T>. If T is also a URI bound, the URID may only be the one that is mapped to the bounded URI.

Since these constraints aren’t checked by this method, it is unsafe. Using this method is technically sound as long as raw_urid is not zero, but might still result in bad behaviour if its the wrong URID for the bound T.

Source

pub fn get(self) -> u32

Return the raw URID number.

Source

pub fn into_general(self) -> URID

Transform the type-specific URID into a generalized one.

Trait Implementations§

Source§

impl<T> Clone for URID<T>
where T: ?Sized,

Source§

fn clone(&self) -> URID<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for URID<T>
where T: ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Hash for URID<T>
where T: ?Sized,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Ord for URID<T>
where T: ?Sized,

Source§

fn cmp(&self, other: &URID<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T1, T2> PartialEq<URID<T1>> for URID<T2>
where T1: ?Sized, T2: ?Sized,

Source§

fn eq(&self, other: &URID<T1>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> PartialEq<u32> for URID<T>
where T: ?Sized,

Source§

fn eq(&self, other: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T1, T2> PartialOrd<URID<T1>> for URID<T2>
where T1: ?Sized, T2: ?Sized,

Source§

fn partial_cmp(&self, other: &URID<T1>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> PartialOrd<u32> for URID<T>
where T: ?Sized,

Source§

fn partial_cmp(&self, other: &u32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<u32> for URID

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: u32) -> Result<URID, ()>

Performs the conversion.
Source§

impl<T> URIDCollection for URID<T>
where T: UriBound + ?Sized,

Source§

fn from_map<M>(map: &M) -> Option<URID<T>>
where M: Map + ?Sized,

Construct the collection from the mapper.
Source§

impl<T> Copy for URID<T>
where T: ?Sized,

Source§

impl<T> Eq for URID<T>
where T: ?Sized,

Auto Trait Implementations§

§

impl<T> Freeze for URID<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for URID<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for URID<T>
where T: Send + ?Sized,

§

impl<T> Sync for URID<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for URID<T>
where T: Unpin + ?Sized,

§

impl<T> UnsafeUnpin for URID<T>
where T: ?Sized,

§

impl<T> UnwindSafe for URID<T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.