Struct zng_app::widget::WidgetId

source ·
pub struct WidgetId(/* private fields */);
Expand description

Unique ID of a widget.

§Name

IDs are only unique for the same process. You can associate a name with an ID to give it a persistent identifier.

§Memory

The internal number is a NonZeroU64, that means that Option<WidgetId> and WidgetId are the same size as u64.

§As Hash

The generated internal number has good statistical distribution and can be used as its own hash, although it is not cryptographically safe, as it is simply a sequential counter scrambled using splitmix64.

§Static

The unique ID cannot be generated at compile time, but you can use the static_id! macro to declare a lazy static that instantiates the ID.

Implementations§

source§

impl WidgetId

source

pub fn new_unique() -> Self

Generates a new unique ID.

source

pub fn get(self) -> u64

Retrieve the underlying value.

source

pub fn sequential(self) -> u64

Un-scramble the underlying value to get the original sequential count number.

If two IDs, id0 and id1 where generated by the same thread then id0.sequential() < id1.sequential().

source

pub fn from_raw(raw: u64) -> Self

Creates an ID from a raw value.

The value must not be zero, panics if it is, the value must have been provided by get otherwise the ID will not be unique.

source

pub fn from_sequential(num: u64) -> Self

Creates an ID from a sequential number.

§Safety

The value must not be zero, panics if it is, the value must have been provided by sequential otherwise the ID will not be unique.

source§

impl WidgetId

source

pub fn named(name: impl Into<Txt>) -> Self

Get or generate an ID with associated name.

If the name is already associated with an ID, returns it. If the name is new, generates a new ID and associated it with the name. If name is an empty string just returns a new ID.

source

pub fn debug_named(name: impl Into<Txt>) -> Self

Calls named in a debug build and new_unique in a release build.

source

pub fn named_new(name: impl Into<Txt>) -> Result<Self, IdNameError<Self>>

Generate a new ID with associated name.

If the name is already associated with an ID, returns the NameUsed error. If the name is an empty string just returns a new ID.

source

pub fn name(self) -> Txt

Returns the name associated with the ID or "".

source

pub fn set_name(self, name: impl Into<Txt>) -> Result<(), IdNameError<Self>>

Associate a name with the ID, if it is not named.

If the name is already associated with a different ID, returns the NameUsed error. If the ID is already named, with a name different from name, returns the AlreadyNamed error. If the name is an empty string or already is the name of the ID, does nothing.

Trait Implementations§

source§

impl Clone for WidgetId

source§

fn clone(&self) -> Self

Returns a copy 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 Debug for WidgetId

source§

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

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

impl<'de> Deserialize<'de> for WidgetId

source§

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

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

impl Display for WidgetId

source§

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

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

impl From<&'static str> for WidgetId

source§

fn from(name: &'static str) -> Self

source§

impl From<Cow<'static, str>> for WidgetId

source§

fn from(name: Cow<'static, str>) -> Self

source§

impl From<String> for WidgetId

source§

fn from(name: String) -> Self

source§

impl From<Txt> for WidgetId

source§

fn from(name: Txt) -> Self

source§

impl From<WidgetId> for AccessNodeId

source§

fn from(id: WidgetId) -> Self

Converts to this type from the input type.
source§

impl From<WidgetId> for CommandScope

source§

fn from(id: WidgetId) -> Self

Converts to this type from the input type.
source§

impl From<char> for WidgetId

source§

fn from(name: char) -> Self

source§

impl Hash for WidgetId

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 IntoVar<AccessNodeId> for WidgetId

§

type Var = LocalVar<AccessNodeId>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> Self::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<CommandScope> for WidgetId

§

type Var = LocalVar<CommandScope>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> Self::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<Option<WidgetId>> for WidgetId

§

type Var = LocalVar<Option<WidgetId>>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> Self::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<WidgetId> for &'static str

source§

fn into_var(self) -> Self::Var

§

type Var = LocalVar<WidgetId>

Variable type that will wrap the T value. Read more
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<WidgetId> for Cow<'static, str>

source§

fn into_var(self) -> Self::Var

§

type Var = LocalVar<WidgetId>

Variable type that will wrap the T value. Read more
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<WidgetId> for String

source§

fn into_var(self) -> Self::Var

§

type Var = LocalVar<WidgetId>

Variable type that will wrap the T value. Read more
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<WidgetId> for Txt

source§

fn into_var(self) -> Self::Var

§

type Var = LocalVar<WidgetId>

Variable type that will wrap the T value. Read more
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl IntoVar<WidgetId> for char

source§

fn into_var(self) -> Self::Var

§

type Var = LocalVar<WidgetId>

Variable type that will wrap the T value. Read more
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
source§

impl PartialEq for WidgetId

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for WidgetId

source§

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

Serialize this value into the given Serde serializer. Read more
source§

impl UniqueId for WidgetId

source§

fn new_unique() -> Self

New unique ID.
source§

impl Copy for WidgetId

source§

impl Eq for WidgetId

source§

impl IntoValue<AccessNodeId> for WidgetId

source§

impl IntoValue<CommandScope> for WidgetId

source§

impl IntoValue<Option<WidgetId>> for WidgetId

source§

impl IntoValue<WidgetId> for &'static str

source§

impl IntoValue<WidgetId> for Cow<'static, str>

source§

impl IntoValue<WidgetId> for String

source§

impl IntoValue<WidgetId> for Txt

source§

impl IntoValue<WidgetId> for char

source§

impl NoUninit for WidgetId

source§

impl PodInOption for WidgetId

source§

impl ZeroableInOption for WidgetId

Auto Trait Implementations§

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> AnyVarValue for T
where T: VarValue,

source§

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

Access to dyn Any methods.
source§

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

Access to mut dyn Any methods.
source§

fn clone_boxed(&self) -> Box<dyn AnyVarValue>

Clone the value.
source§

fn clone_boxed_var(&self) -> Box<dyn AnyVar>

Clone the value into a new boxed LocalVar<Self>.
source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Access to Box<dyn Any> methods.
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
§

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> 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> IntoVar<T> for T
where T: VarValue,

§

type Var = LocalVar<T>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> <T as IntoVar<T>>::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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

source§

default fn to_string(&self) -> String

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

impl<T> ToTxt for T
where T: ToString,

source§

fn to_txt(&self) -> Txt

Converts the given value to an owned Txt. Read more
source§

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

§

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>,

§

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

source§

impl<T> IntoValue<T> for T
where T: VarValue,

source§

impl<T> IpcValue for T
where T: Debug + Serialize + for<'d> Deserialize<'d> + Send + 'static,

source§

impl<T> StateValue for T
where T: Any + Send + Sync,

source§

impl<T> VarValue for T
where T: Debug + Clone + PartialEq + Any + Send + Sync,