Skip to main content

AsyncRowSource

Trait AsyncRowSource 

Source
pub trait AsyncRowSource: Send {
    // Required methods
    fn row_count(&self) -> usize;
    fn column_defs(&self) -> &[ColumnDef];
    fn row_async(
        &self,
        index: usize,
    ) -> BoxFuture<'_, Result<Vec<Cell>, TableError>>;

    // Provided methods
    fn row_height(&self, _index: usize) -> f32 { ... }
    fn footer_async(&self) -> BoxFuture<'_, Option<Vec<Cell>>> { ... }
}
Expand description

Asynchronous variant of RowSource for IO-bound data backends.

Implement this trait for data sources that cannot materialise rows synchronously (e.g. remote databases, networked APIs, lazy disk reads).

§Usage

Wrap an AsyncRowSource in a PrefetchBuffer to obtain a synchronous RowSource that serves rows from cache while background prefetch keeps the buffer warm.

§Thread safety

Implementors are only required to be Send. The PrefetchBuffer wraps the source in an Arc and accesses it exclusively from the async prefetch path, which runs on a single task at a time.

Required Methods§

Source

fn row_count(&self) -> usize

Total number of rows available in the source.

This count is used to size scroll bars and paginate navigation.

Source

fn column_defs(&self) -> &[ColumnDef]

Return the column definitions for this source.

Source

fn row_async( &self, index: usize, ) -> BoxFuture<'_, Result<Vec<Cell>, TableError>>

Asynchronously fetch the cells for the row at index.

Implementations must be cancel-safe. Large in-flight requests may be cancelled when the viewport moves to a different range.

Provided Methods§

Source

fn row_height(&self, _index: usize) -> f32

Per-row height in logical pixels.

Defaults to DEFAULT_ROW_HEIGHT (24 px) for every row.

Source

fn footer_async(&self) -> BoxFuture<'_, Option<Vec<Cell>>>

Optional footer row (aggregate / summary).

Fetched once and cached; invalidate by rebuilding the PrefetchBuffer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§