Skip to main content

ModelId

Struct ModelId 

Source
pub struct ModelId<M: ?Sized> { /* private fields */ }
Expand description

A typed, opaque id for one M row: Copy, 8 bytes, cheap to pass and compare. It wraps the key’s path handle: Store::elem, query results, list slots and destinations all speak it, and a wrong-model id is a compile error rather than a wrong row. ModelId::key recovers the real key for display, deep links, or the persistence edge.

Ordering compares handles: meaningful for integer keys, arbitrary (but stable) for wide ones; it exists so ids can live in sorted containers.

Implementations§

Source§

impl<M: ?Sized> ModelId<M>

Source

pub fn of(key: impl AsKey) -> Self

The id for key, interning it if wide.

Source

pub const fn from_handle(handle: u64) -> Self

Wrap an existing path handle (from Store::keys, a slot token, a change record).

Source

pub fn handle(self) -> u64

Source

pub fn key(self) -> Key

The real key: identity for integer handles, the interner’s record for wide ones.

Trait Implementations§

Source§

impl<M: ?Sized> Clone for ModelId<M>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M: ?Sized> Copy for ModelId<M>

Source§

impl<M: ?Sized> Debug for ModelId<M>

Source§

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

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

impl<M: ?Sized> Eq for ModelId<M>

Source§

impl<M: ?Sized> From<&Key> for ModelId<M>

Source§

fn from(k: &Key) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<&str> for ModelId<M>

Source§

fn from(k: &str) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<Key> for ModelId<M>

Source§

fn from(k: Key) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<String> for ModelId<M>

Source§

fn from(k: String) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<Uuid> for ModelId<M>

Source§

fn from(k: Uuid) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<i32> for ModelId<M>

Source§

fn from(k: i32) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<u32> for ModelId<M>

Source§

fn from(k: u32) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<u64> for ModelId<M>

Raw path handles convert directly; this is how store.elem(k) keeps taking the values Store::keys returns, and how integer keys stay literal-friendly.

Source§

fn from(handle: u64) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> From<usize> for ModelId<M>

Source§

fn from(k: usize) -> Self

Converts to this type from the input type.
Source§

impl<M: ?Sized> Hash for ModelId<M>

Source§

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

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<M: ?Sized> Ord for ModelId<M>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<M: ?Sized> PartialEq for ModelId<M>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<M: ?Sized> PartialEq<ModelId<M>> for u64

Source§

fn eq(&self, other: &ModelId<M>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<M: ?Sized> PartialEq<u64> for ModelId<M>

Integer-keyed ids compare against their key value directly: assert_eq!(ids, [1, 3]) reads the way integer-keyed code always has.

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<M: ?Sized> PartialOrd for ModelId<M>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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

Auto Trait Implementations§

§

impl<M> Freeze for ModelId<M>
where M: ?Sized,

§

impl<M> RefUnwindSafe for ModelId<M>
where M: ?Sized,

§

impl<M> Send for ModelId<M>
where M: ?Sized,

§

impl<M> Sync for ModelId<M>
where M: ?Sized,

§

impl<M> Unpin for ModelId<M>
where M: ?Sized,

§

impl<M> UnsafeUnpin for ModelId<M>
where M: ?Sized,

§

impl<M> UnwindSafe for ModelId<M>
where M: ?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.