Skip to main content

Id

Struct Id 

Source
pub struct Id<T> { /* private fields */ }
Expand description

A key that is not a string, spelled once and kept that way.

Id::new(9u16) names its entry 9, Id::new(some_uuid) names it by the uuid’s own spelling. The rendering is done when the Id is built rather than at every lookup, which is what a Uuid wants most: 36 characters do not fit beside the value, so spelling one costs the heap, and this pays it once for the life of the key instead of once per read.

Entries are listed in the order of the spelling, so Id<u16> lists 10 before 9. A number’s decimal spelling does not order like the number, and nothing here pretends otherwise - padding it would make the name in the file something nobody typed.

Implementations§

Source§

impl<T: Display> Id<T>

Source

pub fn new(value: T) -> Self

Source§

impl<T> Id<T>

Source

pub fn get(&self) -> &T

What was spelled, for a caller that wants the number back.

Source

pub fn into_inner(self) -> T

Trait Implementations§

Source§

impl<T> AsRef<str> for Id<T>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Borrow<str> for Id<T>

So a map keyed by an id can be looked up by the spelling alone, without building one. Sound because Eq and Hash below answer from the same spelling, which is what Borrow asks.

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl<T: Clone> Clone for Id<T>

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<T: Debug> Debug for Id<T>

Source§

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

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

impl<'de, T: Display + FromStr> Deserialize<'de> for Id<T>

Source§

fn deserialize<D: Deserializer<'de>>(from: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for Id<T>

Source§

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

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

impl<T> Eq for Id<T>

Source§

impl<T> Hash for Id<T>

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<T> PartialEq for Id<T>

By the spelling, which is what the store is addressed by and what a listing is ordered by. Two ids that spell alike are one entry whatever they hold.

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<T> ReactiveMapKey for Id<T>
where T: Display + FromStr + Clone + Send + Sync + 'static,

Source§

fn read(name: &str) -> Option<Self>

The key a stored name stands for, or None where that name is not one. Read more
Source§

impl<T> Serialize for Id<T>

As the spelling, so a snapshot holding one for a key is a document with string keys - which is what every format this library writes needs a map’s keys to be.

Source§

fn serialize<S: Serializer>(&self, out: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Id<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Id<T>
where T: RefUnwindSafe,

§

impl<T> Send for Id<T>
where T: Send,

§

impl<T> Sync for Id<T>
where T: Sync,

§

impl<T> Unpin for Id<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Id<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Id<T>
where T: UnwindSafe,

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

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

Source§

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

Source§

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

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

impl<T> FieldValue for T
where T: DeserializeOwned + Serialize + Clone + Send + Sync + 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> OpaqueAttachment for T
where T: Send + Sync + 'static,

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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more