pub struct RemoteRows { /* private fields */ }Expand description
The rows of a DataGrid on a server. The grid asks loader for
a chunk at a time, only for what is on the screen, at most two at once, and keeps a
limited number of them, so a table of any size costs the same to look at.
use ravenrs_widgets::{DataGrid, GridColumn, GridPage, RemoteRows, Value};
let rows = RemoteRows::new(|request, answer| {
// Ask the database here, off the UI thread if it takes a while.
let chunk = (request.offset..request.offset + request.limit)
.map(|n| vec![Value::Number(n as f64)])
.collect();
answer.send(GridPage::new(chunk, true));
});
let grid = DataGrid::remote(rows, [GridColumn::number("N")]);Implementations§
Source§impl RemoteRows
impl RemoteRows
Sourcepub fn new(loader: impl Fn(GridRequest, GridResponder) + 'static) -> Self
pub fn new(loader: impl Fn(GridRequest, GridResponder) + 'static) -> Self
Rows that loader brings, in chunks of 100, keeping 8 of them.
Sourcepub fn chunk_size(self, rows: usize) -> Self
pub fn chunk_size(self, rows: usize) -> Self
How many rows to ask for at a time.
Sourcepub fn max_chunks(self, chunks: usize) -> Self
pub fn max_chunks(self, chunks: usize) -> Self
How many chunks to keep. The memory it takes is this times the chunk size, at most.
Sourcepub fn max_in_flight(self, requests: usize) -> Self
pub fn max_in_flight(self, requests: usize) -> Self
How many questions the server gets at once.
Trait Implementations§
Source§impl Clone for RemoteRows
impl Clone for RemoteRows
Source§fn clone(&self) -> RemoteRows
fn clone(&self) -> RemoteRows
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RemoteRows
impl !Send for RemoteRows
impl !Sync for RemoteRows
impl !UnwindSafe for RemoteRows
impl Freeze for RemoteRows
impl Unpin for RemoteRows
impl UnsafeUnpin for RemoteRows
Blanket Implementations§
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
Mutably borrows from an owned value. Read more