Skip to main content

TodoRepository

Struct TodoRepository 

Source
pub struct TodoRepository { /* private fields */ }
Expand description

SQLite repository for session todo state.

Implementations§

Source§

impl TodoRepository

Source

pub fn new(path: &Path) -> Result<Self, TodoError>

Open or create a todo database at the given path.

§Errors

Returns an error when the database file cannot be opened.

Source

pub fn db_path(&self) -> &Path

Return the path to the SQLite database.

Source

pub fn init_schema(&self) -> Result<(), TodoError>

Initialize todo tables.

§Errors

Returns an error when SQLite rejects the schema.

Source

pub fn create(&self, input: CreateTodo) -> Result<TodoItem, TodoError>

Create a todo item, or return an existing item with the same title in the same session (idempotent create).

§Errors

Returns an error when the item cannot be persisted or looked up.

Source

pub fn create_batch( &self, inputs: Vec<CreateTodo>, ) -> Result<Vec<TodoItem>, TodoError>

Create multiple todo items idempotently in one call.

Each item follows the same idempotency rule as [create]: if an item with the same title already exists in the session, the existing item is returned unchanged. Items within the same batch that share a title also deduplicate to the first occurrence.

§Errors

Returns an error when any item cannot be persisted or looked up.

Source

pub fn get( &self, session_id: Uuid, id: Uuid, ) -> Result<Option<TodoItem>, TodoError>

Get one todo item by id within a session.

§Errors

Returns an error when SQLite fails.

Source

pub fn list( &self, session_id: Uuid, query: TodoQuery, ) -> Result<Vec<TodoItem>, TodoError>

List todo items for a session.

§Errors

Returns an error when SQLite fails or stored metadata cannot be parsed.

Source

pub fn update( &self, session_id: Uuid, id: Uuid, update: TodoUpdate, ) -> Result<TodoItem, TodoError>

Update mutable todo fields.

§Errors

Returns TodoError::NotFound when the item does not exist in the session.

Source

pub fn update_status( &self, session_id: Uuid, id: Uuid, status: TodoStatus, ) -> Result<TodoItem, TodoError>

Update item status and maintain completed_at.

§Errors

Returns TodoError::NotFound when the item does not exist in the session.

Source

pub fn delete(&mut self, session_id: Uuid, id: Uuid) -> Result<bool, TodoError>

Delete an item and any dependency edges that reference it.

§Errors

Returns an error when SQLite fails.

Source

pub fn add_dependency( &self, session_id: Uuid, parent_id: Uuid, child_id: Uuid, ) -> Result<TodoDependency, TodoError>

Add a dependency edge after validating item existence and acyclicity.

§Errors

Returns TodoError::DependencyCycle if adding the edge would create a cycle.

Source

pub fn remove_dependency( &self, session_id: Uuid, parent_id: Uuid, child_id: Uuid, ) -> Result<bool, TodoError>

Remove a dependency edge.

§Errors

Returns an error when SQLite fails.

Source

pub fn list_dependencies( &self, session_id: Uuid, ) -> Result<Vec<TodoDependency>, TodoError>

List all dependency edges for a session.

§Errors

Returns an error when SQLite fails.

Trait Implementations§

Source§

impl Debug for TodoRepository

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.