pub struct AudioOutputId(/* private fields */);Expand description
Unique identifier of an open audio output.
§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 NonZeroU32, that means that
Option<AudioOutputId>
and
AudioOutputId
are the same size as u32.
§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 a modified
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.
§Exhaustion Handling
If more IDs are generated them u32::MAX an error is logged, the internal counter is reset and ids are reused.
Implementations§
Source§impl AudioOutputId
impl AudioOutputId
Sourcepub fn new_unique() -> Self
pub fn new_unique() -> Self
Generates a new unique ID.
Sourcepub fn sequential(self) -> u32
pub fn sequential(self) -> u32
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().
Sourcepub fn from_raw(raw: u32) -> Self
pub fn from_raw(raw: u32) -> 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.
Sourcepub fn from_sequential(num: u32) -> Self
pub fn from_sequential(num: u32) -> 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 AudioOutputId
impl AudioOutputId
Sourcepub fn named(name: impl Into<Txt>) -> Self
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.
Sourcepub fn debug_named(name: impl Into<Txt>) -> Self
pub fn debug_named(name: impl Into<Txt>) -> Self
Calls named in a debug build and new_unique in a release build.
Sourcepub fn named_new(name: impl Into<Txt>) -> Result<Self, IdNameError<Self>>
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.
Sourcepub fn set_name(self, name: impl Into<Txt>) -> Result<(), IdNameError<Self>>
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 AudioOutputId
impl Clone for AudioOutputId
Source§impl Debug for AudioOutputId
impl Debug for AudioOutputId
Source§impl<'de> Deserialize<'de> for AudioOutputId
impl<'de> Deserialize<'de> for AudioOutputId
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for AudioOutputId
impl Display for AudioOutputId
Source§impl From<&'static str> for AudioOutputId
impl From<&'static str> for AudioOutputId
Source§fn from(name: &'static str) -> Self
fn from(name: &'static str) -> Self
Calls AudioOutputId::named.
Source§impl From<String> for AudioOutputId
impl From<String> for AudioOutputId
Source§fn from(name: String) -> Self
fn from(name: String) -> Self
Calls AudioOutputId::named.
Source§impl From<Txt> for AudioOutputId
impl From<Txt> for AudioOutputId
Source§fn from(name: Txt) -> Self
fn from(name: Txt) -> Self
Calls AudioOutputId::named.
Source§impl From<char> for AudioOutputId
impl From<char> for AudioOutputId
Source§fn from(name: char) -> Self
fn from(name: char) -> Self
Calls AudioOutputId::named.
Source§impl Hash for AudioOutputId
impl Hash for AudioOutputId
Source§impl IntoVar<AudioOutputId> for &'static str
impl IntoVar<AudioOutputId> for &'static str
Source§fn into_var(self) -> Var<AudioOutputId>
fn into_var(self) -> Var<AudioOutputId>
Calls AudioOutputId::named.
Source§impl IntoVar<AudioOutputId> for Cow<'static, str>
impl IntoVar<AudioOutputId> for Cow<'static, str>
Source§fn into_var(self) -> Var<AudioOutputId>
fn into_var(self) -> Var<AudioOutputId>
Calls AudioOutputId::named.
Source§impl IntoVar<AudioOutputId> for String
impl IntoVar<AudioOutputId> for String
Source§fn into_var(self) -> Var<AudioOutputId>
fn into_var(self) -> Var<AudioOutputId>
Calls AudioOutputId::named.
Source§impl IntoVar<AudioOutputId> for Txt
impl IntoVar<AudioOutputId> for Txt
Source§fn into_var(self) -> Var<AudioOutputId>
fn into_var(self) -> Var<AudioOutputId>
Calls AudioOutputId::named.
Source§impl IntoVar<AudioOutputId> for char
impl IntoVar<AudioOutputId> for char
Source§fn into_var(self) -> Var<AudioOutputId>
fn into_var(self) -> Var<AudioOutputId>
Calls AudioOutputId::named.
Source§impl IntoVar<Option<AudioOutputId>> for AudioOutputId
impl IntoVar<Option<AudioOutputId>> for AudioOutputId
Source§impl PartialEq for AudioOutputId
impl PartialEq for AudioOutputId
Source§impl Serialize for AudioOutputId
impl Serialize for AudioOutputId
Source§impl UniqueId for AudioOutputId
impl UniqueId for AudioOutputId
Source§fn new_unique() -> Self
fn new_unique() -> Self
impl Copy for AudioOutputId
impl Eq for AudioOutputId
impl IntoValue<AudioOutputId> for &'static str
impl IntoValue<AudioOutputId> for Cow<'static, str>
impl IntoValue<AudioOutputId> for String
impl IntoValue<AudioOutputId> for Txt
impl IntoValue<AudioOutputId> for char
impl IntoValue<Option<AudioOutputId>> for AudioOutputId
impl NoUninit for AudioOutputId
impl PodInOption for AudioOutputId
impl ZeroableInOption for AudioOutputId
Auto Trait Implementations§
impl Freeze for AudioOutputId
impl RefUnwindSafe for AudioOutputId
impl Send for AudioOutputId
impl Sync for AudioOutputId
impl Unpin for AudioOutputId
impl UnwindSafe for AudioOutputId
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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