Struct aper::data_structures::List
source · pub struct List<T: StateMachine + PartialEq> { /* private fields */ }
Expand description
Represents a list of items, similar to a Vec
, but designed to be robust
to concurrent modifications from multiple users.
Implementations§
source§impl<T: StateMachine + PartialEq> List<T>
impl<T: StateMachine + PartialEq> List<T>
pub fn new() -> List<T>
pub fn get_location(&self, position: &ListPosition) -> ZenoIndex
pub fn insert_between( &self, id1: &Uuid, id2: &Uuid, value: T ) -> OperationWithId<T>
sourcepub fn append(&self, value: T) -> OperationWithId<T>
pub fn append(&self, value: T) -> OperationWithId<T>
Construct an OperationWithId representing appending the given object to this list.
sourcepub fn prepend(&self, value: T) -> OperationWithId<T>
pub fn prepend(&self, value: T) -> OperationWithId<T>
Construct a OperationWithId representing prepending the given object to this list.
sourcepub fn insert(&self, location: ZenoIndex, value: T) -> OperationWithId<T>
pub fn insert(&self, location: ZenoIndex, value: T) -> OperationWithId<T>
Construct a OperationWithId representing inserting the given object at the given location in this list.
sourcepub fn delete(&self, id: Uuid) -> ListOperation<T>
pub fn delete(&self, id: Uuid) -> ListOperation<T>
Construct a ListOperation representing deleting the object given (by id) in this list.
sourcepub fn move_item(&self, id: Uuid, new_location: ZenoIndex) -> ListOperation<T>
pub fn move_item(&self, id: Uuid, new_location: ZenoIndex) -> ListOperation<T>
Construct a ListOperation representing moving an object already in this list to the given location in the list.
pub fn map_item( &self, id: Uuid, fun: impl FnOnce(&T) -> <T as StateMachine>::Transition ) -> <Self as StateMachine>::Transition
Trait Implementations§
source§impl<'de, T: StateMachine + PartialEq> Deserialize<'de> for List<T>
impl<'de, T: StateMachine + PartialEq> Deserialize<'de> for List<T>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<T: PartialEq + StateMachine + PartialEq> PartialEq for List<T>
impl<T: PartialEq + StateMachine + PartialEq> PartialEq for List<T>
source§impl<T: StateMachine + PartialEq> StateMachine for List<T>
impl<T: StateMachine + PartialEq> StateMachine for List<T>
§type Transition = ListOperation<T>
type Transition = ListOperation<T>
The
StateMachine::Transition
type associates another type with this state machine
as its transitions.type Conflict = ListConflict<T>
source§fn apply(
&self,
transition_event: &Self::Transition
) -> Result<Self, ListConflict<T>>
fn apply( &self, transition_event: &Self::Transition ) -> Result<Self, ListConflict<T>>
Update the state machine according to the given [
Transition
]. This method must be
deterministic: calling it on a clone of the state with a clone of the [Transition
]
must result in the same state, even at a different time and on a different machine. This
is the requirement that allows Aper to keep the state in sync across multiple machines.impl<T: StateMachine + PartialEq> StructuralPartialEq for List<T>
Auto Trait Implementations§
impl<T> Freeze for List<T>
impl<T> RefUnwindSafe for List<T>where
T: RefUnwindSafe,
impl<T> !Send for List<T>
impl<T> !Sync for List<T>
impl<T> Unpin for List<T>where
T: Unpin,
impl<T> UnwindSafe for List<T>where
T: RefUnwindSafe + UnwindSafe,
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
Mutably borrows from an owned value. Read more