Struct flo_binding::RopeBinding
source · [−]pub struct RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Unpin + Clone + PartialEq + Default, { /* private fields */ }
Expand description
A rope binding binds a vector of cells and attributes
It’s also possible to use a normal Binding<Vec<_>>
for this purpose. A rope binding has a
couple of advantages though: it can handle very large collections of items and it can notify
only the relevant changes instead of always notifying the entire structure.
Rope bindings are ideal for representing text areas in user interfaces, but can be used for any collection data structure.
Implementations
sourceimpl<Cell, Attribute> RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
impl<Cell, Attribute> RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
sourcepub fn from_mutable(binding: &RopeBindingMut<Cell, Attribute>) -> Self
pub fn from_mutable(binding: &RopeBindingMut<Cell, Attribute>) -> Self
Generates a rope binding by tracking a mutable binding
sourcepub fn from_stream<S: 'static + Stream<Item = RopeAction<Cell, Attribute>> + Unpin + Send>(
stream: S
) -> Self
pub fn from_stream<S: 'static + Stream<Item = RopeAction<Cell, Attribute>> + Unpin + Send>(
stream: S
) -> Self
Creates a new rope binding from a stream of changes
sourcepub fn computed<TFn: 'static + Send + Fn() -> TValueIter, TValueIter: IntoIterator<Item = Cell>>(
calculate_value: TFn
) -> Self
pub fn computed<TFn: 'static + Send + Fn() -> TValueIter, TValueIter: IntoIterator<Item = Cell>>(
calculate_value: TFn
) -> Self
Creates a rope binding that entirely replaces its set of cells by following a computed value (the attributes will always have their default values when using this method)
sourcepub fn read_cells<'a>(
&'a self,
range: Range<usize>
) -> impl 'a + Iterator<Item = Cell>
pub fn read_cells<'a>(
&'a self,
range: Range<usize>
) -> impl 'a + Iterator<Item = Cell>
Reads the cell values for a range in this rope
sourceimpl<Cell, Attribute> RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq + Hash + Ord + Eq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
impl<Cell, Attribute> RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq + Hash + Ord + Eq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
sourcepub fn computed_difference<TFn: 'static + Send + Fn() -> TValueIter, TValueIter: IntoIterator<Item = Cell>>(
calculate_value: TFn
) -> Self
pub fn computed_difference<TFn: 'static + Send + Fn() -> TValueIter, TValueIter: IntoIterator<Item = Cell>>(
calculate_value: TFn
) -> Self
Similar to computed, but instead of always replacing the entire rope, replaces only the sections that are different between the two values.
This currently stores up to three copies of the list of cells (generally only two, but up to three while computing diffs). This
is not efficient for sending edits, but useful when they’re not easily known. Use RopeBindingMut
to send edits as they arrive
instead.
In spite of this, this is still useful when updating something like a user interface where only the changes should be sent to the user, or for generating edit lists when the data source is not already formatted in a suitable form.
Trait Implementations
sourceimpl<Cell, Attribute> Bound<AttributedRope<Cell, Attribute>> for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
impl<Cell, Attribute> Bound<AttributedRope<Cell, Attribute>> for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
Trait implemented by something that is bound to a value
sourcefn get(&self) -> AttributedRope<Cell, Attribute>
fn get(&self) -> AttributedRope<Cell, Attribute>
Retrieves the value stored by this binding
sourceimpl<Cell, Attribute> BoundRope<Cell, Attribute> for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
impl<Cell, Attribute> BoundRope<Cell, Attribute> for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
sourcefn follow_changes(&self) -> RopeStream<Cell, Attribute>
fn follow_changes(&self) -> RopeStream<Cell, Attribute>
Creates a stream that follows the changes to this rope
sourcefn follow_changes_retained(&self) -> RopeStream<Cell, Attribute>
fn follow_changes_retained(&self) -> RopeStream<Cell, Attribute>
Creates a stream that follows the changes to this rope
The stream will continue even if the rope binding is dropped (this is possible for RopeBinding as RopeBinding itself might be following a stream)
sourceimpl<Cell, Attribute> Changeable for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
impl<Cell, Attribute> Changeable for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
sourcefn when_changed(&self, what: Arc<dyn Notifiable>) -> Box<dyn Releasable>
fn when_changed(&self, what: Arc<dyn Notifiable>) -> Box<dyn Releasable>
Supplies a function to be notified when this item is changed
This event is only fired after the value has been read since the most recent change. Note that this means if the value is never read, this event may never fire. This behaviour is desirable when deferring updates as it prevents large cascades of ‘changed’ events occurring for complicated dependency trees.
The releasable that’s returned has keep_alive turned off by default, so be sure to store it in a variable or call keep_alive() to keep it around (if the event never seems to fire, this is likely to be the problem)
sourceimpl<Cell, Attribute> Clone for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
impl<Cell, Attribute> Clone for RopeBinding<Cell, Attribute> where
Cell: 'static + Send + Unpin + Clone + PartialEq,
Attribute: 'static + Send + Sync + Clone + Unpin + PartialEq + Default,
sourcefn clone(&self) -> RopeBinding<Cell, Attribute>
fn clone(&self) -> RopeBinding<Cell, Attribute>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<Cell, Attribute> !RefUnwindSafe for RopeBinding<Cell, Attribute>
impl<Cell, Attribute> Send for RopeBinding<Cell, Attribute>
impl<Cell, Attribute> Sync for RopeBinding<Cell, Attribute>
impl<Cell, Attribute> Unpin for RopeBinding<Cell, Attribute>
impl<Cell, Attribute> !UnwindSafe for RopeBinding<Cell, Attribute>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more