pub struct Selector<K: 'static> { /* private fields */ }Expand description
An Owner-owned index for a single selected key (Cage<Option<K>>).
selected(key) creates one read-only selection handle per live key/Owner,
owned by the current construction Owner (or the selector Owner outside
construction). Reads subscribe to that channel, not the shared selection.
A flush normally notifies only the old and new key’s live channels; batched
changes coalesce to the final key. Channels actually read ahead of a flush
are also notified once, including after a net-zero batch, to invalidate any
cached intermediate result. Direct Selected::get reads compare against the
current source, including inside a batch before notification. This is not a general predicate
selector. Bind through computed(move || selected.get()); this dedicated
handle does not implicitly convert to Vary<bool>.
A derived Bond caching a selection read is invalidated by the flush-time
notification, so it may retain its previous value until that flush. Use the
Selected handle directly when reading intermediate, unflushed writes.
Keys must have pure, stable Clone/Hash/Eq implementations. Hash collisions compare complete keys outside graph/index borrows. Storage contains only live registered channels; retirement removes empty buckets. Handles are local, non-owning, invalid after their creating Owner retires. Register channels during construction, not inside pure computations.
Implementations§
Source§impl<K: Clone + Eq + Hash + 'static> Selector<K>
impl<K: Clone + Eq + Hash + 'static> Selector<K>
pub fn selected(self, key: K) -> Selected<K>
pub fn try_selected(self, key: K) -> Result<Selected<K>, AccessError>
Sourcepub fn stats(self) -> Result<SelectorStats, AccessError>
pub fn stats(self) -> Result<SelectorStats, AccessError>
Explicit O(live channels) diagnostics; no source or visited-key scan.