1mod cache;
12mod layout;
13mod measure;
14mod navigation;
15mod scroll;
16mod widget;
17pub use widget::{List, ListStats, list};
18
19pub use cache::{Cache, ReconcileStats, RowHost};
20pub use layout::{Anchor, Heights, Layout, Window};
21pub use scroll::{ScrollSpace, ScrollUpdate};
22
23pub const MAX_EXTENT: f64 = 281_474_976_710_656.0;
26
27pub const DEFAULT_ROW_LIMIT: usize = 4096;
30
31#[derive(Clone, Debug, PartialEq, Eq)]
32pub enum Error {
33 InvalidSize,
34 OutOfBounds,
35 Allocation,
36 DuplicateKey,
37 InvalidRange,
38 InvalidLookup,
39 InvalidAnchor,
40 RowLimit { requested: usize, limit: usize },
41}
42
43fn check_rows(requested: usize, limit: usize) -> Result<(), Error> {
44 if requested > limit {
45 Err(Error::RowLimit { requested, limit })
46 } else {
47 Ok(())
48 }
49}
50
51impl std::fmt::Display for Error {
52 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53 write!(f, "{self:?}")
54 }
55}
56impl std::error::Error for Error {}
57
58fn positive(value: f64) -> bool {
59 value.is_finite() && value > 0.0
60}
61fn nonnegative(value: f64) -> bool {
62 value.is_finite() && value >= 0.0
63}
64fn valid_extent(value: f64) -> bool {
65 nonnegative(value) && value <= MAX_EXTENT
66}