Skip to main content

Store

Trait Store 

Source
pub trait Store {
    // Required methods
    fn next_id(&mut self) -> TodoId;
    fn insert(&mut self, todo: Todo);
    fn get(&self, id: TodoId) -> Option<Todo>;
    fn list(&self) -> Vec<Todo>;
    fn update(&mut self, todo: Todo);
    fn remove(&mut self, id: TodoId);
}
Expand description

Backing store for todo items. Implementations may be in-memory or persistent.

Required Methods§

Source

fn next_id(&mut self) -> TodoId

Returns the next available id and advances the counter.

Source

fn insert(&mut self, todo: Todo)

Inserts a todo; the id must have been obtained from next_id.

Source

fn get(&self, id: TodoId) -> Option<Todo>

Returns the todo with the given id, if any.

Source

fn list(&self) -> Vec<Todo>

Returns all todos in creation order (by created_at).

Source

fn update(&mut self, todo: Todo)

Updates an existing todo (e.g. after marking completed).

Source

fn remove(&mut self, id: TodoId)

Removes the todo with the given id.

Implementors§