pub struct HIGHLIGHTS { /* private fields */ }
Expand description
The highlights
table from the global Config
.
This cell is guaranteed to be initialized during the execution of all
PanelConfig::parse
functions.
Methods from Deref<Target = OnceCell<HashMap<String, Value>>>§
Sourcepub fn initialized(&self) -> bool
pub fn initialized(&self) -> bool
Returns true
if the OnceCell
currently contains a value, and false
otherwise.
Sourcepub fn get(&self) -> Option<&T>
pub fn get(&self) -> Option<&T>
Returns a reference to the value currently stored in the OnceCell
, or
None
if the OnceCell
is empty.
Sourcepub fn set(&self, value: T) -> Result<(), SetError<T>>
pub fn set(&self, value: T) -> Result<(), SetError<T>>
Sets the value of the OnceCell
to the given value if the OnceCell
is
empty.
If the OnceCell
already has a value, this call will fail with an
SetError::AlreadyInitializedError
.
If the OnceCell
is empty, but some other task is currently trying to
set the value, this call will fail with SetError::InitializingError
.
Sourcepub async fn get_or_init<F, Fut>(&self, f: F) -> &T
pub async fn get_or_init<F, Fut>(&self, f: F) -> &T
Gets the value currently in the OnceCell
, or initialize it with the
given asynchronous operation.
If some other task is currently working on initializing the OnceCell
,
this call will wait for that other task to finish, then return the value
that the other task produced.
If the provided operation is cancelled or panics, the initialization attempt is cancelled. If there are other tasks waiting for the value to be initialized, one of them will start another attempt at initializing the value.
This will deadlock if f
tries to initialize the cell recursively.
Sourcepub async fn get_or_try_init<E, F, Fut>(&self, f: F) -> Result<&T, E>
pub async fn get_or_try_init<E, F, Fut>(&self, f: F) -> Result<&T, E>
Gets the value currently in the OnceCell
, or initialize it with the
given asynchronous operation.
If some other task is currently working on initializing the OnceCell
,
this call will wait for that other task to finish, then return the value
that the other task produced.
If the provided operation returns an error, is cancelled or panics, the initialization attempt is cancelled. If there are other tasks waiting for the value to be initialized, one of them will start another attempt at initializing the value.
This will deadlock if f
tries to initialize the cell recursively.