Dispatch

Trait Dispatch 

Source
pub trait Dispatch {
    type ReadOperation: Sized + Clone + PartialEq + Debug;
    type WriteOperation: Sized + Clone + PartialEq + Debug + Send;
    type Response: Sized + Clone;

    // Required methods
    fn dispatch(&self, op: Self::ReadOperation) -> Self::Response;
    fn dispatch_mut(&mut self, op: Self::WriteOperation) -> Self::Response;
}
Expand description

Trait that a data structure must implement to be usable with this library.

When this library executes a read-only operation against the data structure, it invokes the dispatch() method with the operation as an argument.

When this library executes a write operation against the data structure, it invokes the dispatch_mut() method with the operation as an argument.

Required Associated Types§

Source

type ReadOperation: Sized + Clone + PartialEq + Debug

A read-only operation. When executed against the data structure, an operation of this type must not mutate the data structure in anyway. Otherwise, the assumptions made by this library no longer hold.

Source

type WriteOperation: Sized + Clone + PartialEq + Debug + Send

A write operation. When executed against the data structure, an operation of this type is allowed to mutate state. The library ensures that this is done so in a thread-safe manner.

Source

type Response: Sized + Clone

The type on the value returned by the data structure when a ReadOperation or a WriteOperation successfully executes against it.

Required Methods§

Source

fn dispatch(&self, op: Self::ReadOperation) -> Self::Response

Method on the data structure that allows a read-only operation to be executed against it.

Source

fn dispatch_mut(&mut self, op: Self::WriteOperation) -> Self::Response

Method on the data structure that allows a write operation to be executed against it.

Implementors§