Skip to main content

ModelId

Struct ModelId 

Source
pub struct ModelId<M>
where 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> ModelId<M>
where M: ?Sized,

Source

pub fn of(key: impl AsKey) -> ModelId<M>

The id for key, interning it if wide.

Source

pub const fn from_handle(handle: u64) -> ModelId<M>

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> Clone for ModelId<M>
where M: ?Sized,

Source§

fn clone(&self) -> ModelId<M>

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> Copy for ModelId<M>
where M: ?Sized,

Source§

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

Source§

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

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

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

Source§

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

Source§

fn from(k: &Key) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: &str) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: Key) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: String) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: Uuid) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: i32) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: u32) -> ModelId<M>

Converts to this type from the input type.
Source§

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

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) -> ModelId<M>

Converts to this type from the input type.
Source§

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

Source§

fn from(k: usize) -> ModelId<M>

Converts to this type from the input type.
Source§

impl<M> Hash for ModelId<M>
where M: ?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<M> Ord for ModelId<M>
where M: ?Sized,

Source§

fn cmp(&self, other: &ModelId<M>) -> 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> PartialEq for ModelId<M>
where M: ?Sized,

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> PartialEq<u64> for ModelId<M>
where M: ?Sized,

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> PartialOrd for ModelId<M>
where M: ?Sized,

Source§

fn partial_cmp(&self, other: &ModelId<M>) -> 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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.