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>

source

pub fn new() -> List<T>

source

pub fn get_location(&self, position: &ListPosition) -> ZenoIndex

source

pub fn insert_between( &self, id1: &Uuid, id2: &Uuid, value: T ) -> OperationWithId<T>

source

pub fn append(&self, value: T) -> OperationWithId<T>

Construct an OperationWithId representing appending the given object to this list.

source

pub fn prepend(&self, value: T) -> OperationWithId<T>

Construct a OperationWithId representing prepending the given object to this list.

source

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.

source

pub fn delete(&self, id: Uuid) -> ListOperation<T>

Construct a ListOperation representing deleting the object given (by id) in this list.

source

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.

source

pub fn map_item( &self, id: Uuid, fun: impl FnOnce(&T) -> <T as StateMachine>::Transition ) -> <Self as StateMachine>::Transition

source

pub fn iter(&self) -> impl Iterator<Item = ListItem<'_, T>>

Returns an iterator over ListItem views into this list.

Trait Implementations§

source§

impl<T: Clone + StateMachine + PartialEq> Clone for List<T>

source§

fn clone(&self) -> List<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + StateMachine + PartialEq> Debug for List<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: StateMachine + PartialEq> Default for List<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, T: StateMachine + PartialEq> Deserialize<'de> for List<T>

source§

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>

source§

fn eq(&self, other: &List<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: StateMachine + PartialEq> Serialize for List<T>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: StateMachine + PartialEq> StateMachine for List<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>>

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.
source§

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>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,