pub struct AvatarState { /* private fields */ }Expand description
Controlled, allocation-free load state for one avatar.
The application owns which source it loads and reports the result; QuickGUI owns the exact
fallback deadline that keeps a brief load from flashing initials on screen. Nothing here polls:
Self::next_deadline reports the single instant the owner should ask for one repaint, and
Self::poll applies it. A settled avatar reports no deadline at all.
Implementations§
Source§impl AvatarState
impl AvatarState
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Declare an avatar with no source yet, whose fallback is visible immediately.
Sourcepub fn delay(self, delay: Duration) -> Self
pub fn delay(self, delay: Duration) -> Self
Hold the fallback back for delay after loading starts.
This is Base UI’s Avatar.Fallback delay. A zero delay shows the fallback immediately;
anything longer than MAX_AVATAR_FALLBACK_DELAY is clamped to it, and a non-finite or
unrepresentable value falls back to zero.
pub const fn loading_status(&self) -> AvatarLoadingStatus
pub const fn fallback_delay(&self) -> Duration
Sourcepub fn set_loading_status(
&mut self,
status: AvatarLoadingStatus,
now: Instant,
) -> bool
pub fn set_loading_status( &mut self, status: AvatarLoadingStatus, now: Instant, ) -> bool
Replace the retained load status, returning whether it changed.
Entering AvatarLoadingStatus::Loading or AvatarLoadingStatus::Idle arms the exact
fallback deadline; AvatarLoadingStatus::Error shows the fallback at once, and
AvatarLoadingStatus::Loaded disarms it.
Sourcepub const fn next_deadline(&self) -> Option<Instant>
pub const fn next_deadline(&self) -> Option<Instant>
The single instant a repaint is needed, or None while the avatar is settled.
Sourcepub fn poll(&mut self, now: Instant) -> bool
pub fn poll(&mut self, now: Instant) -> bool
Retire an elapsed fallback deadline, returning whether the visible state changed.
Sourcepub const fn shows_image(&self) -> bool
pub const fn shows_image(&self) -> bool
Whether the image part should be mounted.
Sourcepub const fn shows_fallback(&self) -> bool
pub const fn shows_fallback(&self) -> bool
Whether the fallback part should be mounted.
A loaded image hides the fallback; an unloaded one shows it only once the declared delay has elapsed, which is why a fast cache hit never flashes initials.
Trait Implementations§
Source§impl Clone for AvatarState
impl Clone for AvatarState
impl Copy for AvatarState
Source§impl Debug for AvatarState
impl Debug for AvatarState
Source§impl Default for AvatarState
impl Default for AvatarState
Source§impl PartialEq for AvatarState
impl PartialEq for AvatarState
impl StructuralPartialEq for AvatarState
Auto Trait Implementations§
impl Forget for AvatarState
impl Freeze for AvatarState
impl Move for AvatarState
impl RefUnwindSafe for AvatarState
impl Send for AvatarState
impl Sync for AvatarState
impl Unpin for AvatarState
impl UnsafeUnpin for AvatarState
impl UnwindSafe for AvatarState
Blanket Implementations§
impl<T> Action for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.