Skip to content

Replace trait SharedData with DataAccessor#487

Merged
dhardy merged 14 commits intomasterfrom
push-wpksnrpwtkyu
Apr 6, 2025
Merged

Replace trait SharedData with DataAccessor#487
dhardy merged 14 commits intomasterfrom
push-wpksnrpwtkyu

Conversation

@dhardy
Copy link
Copy Markdown
Collaborator

@dhardy dhardy commented Apr 3, 2025

Revise how the kas-view traits work:

  • Remove traits SharedData, ListData, MatrixData
  • Add trait DataAccessor<Index> where Index is usize for ListView or (usize, usize) for MatrixView; queries are simplified relative to List/MatrixData while supporting async results
  • Tweak trait Driver: change generic parameters, rename fn on_messageshandle_messages and change its parameter data to &Item.
  • Replace widget FilterBoxList with FilterBoxListView, a similar but more constrained widget over the new DataAccessor trait.
  • Remove widget FilterList and UnsafeFilteredList adaptor.

Unfinished in this PR: scroll bars require the data len to calculate their length properly; for this reason primarily we require that fn len return a fixed Index value. We should allow some flexibility here, maybe like Iterator::size_hint or maybe some other way. For now we just document the limitation.

Another limitation is that fn DataAccessor::item must return a reference. It could return an Option<Cow<Self::Item>> instead to allow in-place generation of values, or maybe something like impl Option<Borrow<Self::Item>>. Is the extra API complexity worth it? Note also that the API usage expects that fn item is fast.

Yet another limitation: FilterBoxListView accepts &() input data since its filter is passed as input data to the data accessor. Ideally both filter and this widget's input data would be passed into the accessor, but our input data model is too limited to allow this (#488).

Also:

  • Rename fns push_async, push_async_erased, push_spawn to send_* since they take id as input like fn send unlike fn push.
  • autoimpl trait Scrollable for MapAny

@dhardy dhardy force-pushed the push-wpksnrpwtkyu branch from 7ecc8fe to 25f3111 Compare April 5, 2025 11:34
@dhardy dhardy merged commit fa12711 into master Apr 6, 2025
5 checks passed
@dhardy dhardy deleted the push-wpksnrpwtkyu branch April 7, 2025 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant