Skip to main content

LoadSlot

Struct LoadSlot 

Source
pub struct LoadSlot<T: 'static> { /* private fields */ }
Expand description

单槽异步加载:同一时刻只有一个在飞的任务,新请求取消旧请求。

T: 'static 是 Signal 的要求(状态要能被任务回调跨帧持有)。

Implementations§

Source§

impl<T: Clone + 'static> LoadSlot<T>

Source

pub fn new(state: Signal<LoadState<T>>) -> Self

Source

pub fn state(&self) -> &Signal<LoadState<T>>

进度载体:组件读它的 status() / data()。

Source

pub fn status(&self) -> LoadStatus

Source

pub fn is_pending(&self) -> bool

Source

pub fn load<Fut, M>(&self, tasks: &TaskExecutor, make: M)
where Fut: Future<Output = Result<T, String>> + 'static, M: FnOnce() -> Fut,

发起(或取代)一次取数。make 只在被启动时执行一次。

Source

pub fn cancel(&self)

取消在飞任务并复位进度:首载回到 Idle,刷新回到 Ready(旧数据仍可画)。

Source

pub fn finish(&self, value: T)

手动写入成功结果(用于同步数据源或本地计算)。

Source

pub fn fail(&self, message: impl Into<Rc<str>>)

手动写入失败原因。

Trait Implementations§

Source§

impl<T: Clone + 'static> Clone for LoadSlot<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

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for LoadSlot<T>

§

impl<T> !Send for LoadSlot<T>

§

impl<T> !Sync for LoadSlot<T>

§

impl<T> !UnwindSafe for LoadSlot<T>

§

impl<T> Freeze for LoadSlot<T>
where Signal<LoadState<T>>: Freeze,

§

impl<T> Unpin for LoadSlot<T>
where Signal<LoadState<T>>: Unpin,

§

impl<T> UnsafeUnpin for LoadSlot<T>

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, 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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>