pub struct SceneListAdapter<T: 'static> { /* private fields */ }Expand description
Keeps a set of lightweight SceneItems in sync with a
teksilo_data::ListModel<T> / ListDataSource<Item = T>.
Not a Widget — a plain handle you construct once (typically from a
composing widget’s build() or app setup code) and keep alive for as
long as the sync should run. See the module docs for the delegate
contract, reconciliation policy, and borrow discipline.
§Dropping
Dropping a SceneListAdapter drops its [ObserverHandle], which stops
the adapter from reacting to further source changes. It deliberately
does not remove the adapter’s items from the scene — running scene
mutations from inside a Drop impl risks a re-entrant borrow of the
shared RefCell<Scene> if the drop happens while some other code
already holds a borrow (e.g. mid-notification). Call
clear first if you want the items gone before dropping.
Implementations§
Source§impl<T: 'static> SceneListAdapter<T>
impl<T: 'static> SceneListAdapter<T>
Sourcepub fn from_model(
model: &ListModel<T>,
scene: SceneModel,
delegate: impl Fn(&T, usize) -> Box<dyn SceneItem> + 'static,
) -> Self
pub fn from_model( model: &ListModel<T>, scene: SceneModel, delegate: impl Fn(&T, usize) -> Box<dyn SceneItem> + 'static, ) -> Self
Track model’s rows as scene items in scene, built by delegate.
Materialises every current row immediately (as if a DataChange::Reset
had just fired), then keeps the scene in sync via
ListModel::observe_changes for as long as the returned adapter is
alive. See the module docs for the delegate contract and
reconciliation policy.
Sourcepub fn from_source<S: ListDataSource<Item = T> + 'static>(
source: Rc<S>,
scene: SceneModel,
delegate: impl Fn(&T, usize) -> Box<dyn SceneItem> + 'static,
) -> Self
pub fn from_source<S: ListDataSource<Item = T> + 'static>( source: Rc<S>, scene: SceneModel, delegate: impl Fn(&T, usize) -> Box<dyn SceneItem> + 'static, ) -> Self
Track an external ListDataSource’s rows as scene items in scene,
built by delegate.
Takes source as an Rc<S> (rather than by value) so the caller can
keep its own handle to the same source alongside the adapter — the
same convention as ListView::from_source / TableView’s erasure.
See Self::from_model for the materialisation + reconciliation
behaviour, which is identical for both constructors.
Sourcepub fn item_id_at(&self, index: usize) -> Option<ItemId>
pub fn item_id_at(&self, index: usize) -> Option<ItemId>
The scene item id materialised for data row index, or None if
index is out of range or the row has no materialised item (an
unloaded row of a windowed source).
Auto Trait Implementations§
impl<T> !RefUnwindSafe for SceneListAdapter<T>
impl<T> !Send for SceneListAdapter<T>
impl<T> !Sync for SceneListAdapter<T>
impl<T> !UnwindSafe for SceneListAdapter<T>
impl<T> Freeze for SceneListAdapter<T>
impl<T> Unpin for SceneListAdapter<T>where
T: Unpin,
impl<T> UnsafeUnpin for SceneListAdapter<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more