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§
Sourcetype ReadOperation: Sized + Clone + PartialEq + Debug
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.
Required Methods§
Sourcefn dispatch(&self, op: Self::ReadOperation) -> Self::Response
fn dispatch(&self, op: Self::ReadOperation) -> Self::Response
Method on the data structure that allows a read-only operation to be executed against it.
Sourcefn dispatch_mut(&mut self, op: Self::WriteOperation) -> Self::Response
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.