mod cache;
mod layout;
mod measure;
mod navigation;
mod scroll;
mod widget;
pub use widget::{List, ListStats, list};
pub use cache::{Cache, ReconcileStats, RowHost};
pub use layout::{Anchor, Heights, Layout, Window};
pub use scroll::{ScrollSpace, ScrollUpdate};
pub const MAX_EXTENT: f64 = 281_474_976_710_656.0;
pub const DEFAULT_ROW_LIMIT: usize = 4096;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Error {
InvalidSize,
OutOfBounds,
Allocation,
DuplicateKey,
InvalidRange,
InvalidLookup,
InvalidAnchor,
RowLimit { requested: usize, limit: usize },
}
fn check_rows(requested: usize, limit: usize) -> Result<(), Error> {
if requested > limit {
Err(Error::RowLimit { requested, limit })
} else {
Ok(())
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for Error {}
fn positive(value: f64) -> bool {
value.is_finite() && value > 0.0
}
fn nonnegative(value: f64) -> bool {
value.is_finite() && value >= 0.0
}
fn valid_extent(value: f64) -> bool {
nonnegative(value) && value <= MAX_EXTENT
}