diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bd8fef..5f2fde1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Procedure when bumping the version number: - Error handling of `Action`s is now more complex but more powerful. In particular, `Action`s can now return almost arbitrary errors without nesting `Result`s like before. +- Renamed `Action::Result` to `Action::Output` ## v0.1.0 - 2023-02-12 diff --git a/src/lib.rs b/src/lib.rs index f834b0e..bf7ecf9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,9 +23,9 @@ use rusqlite::{Connection, Transaction}; /// Actions are usually passed to a vault which will then execute them and /// return the result. The way in which this occurs depends on the vault. pub trait Action { - type Result; + type Output; type Error; - fn run(self, conn: &mut Connection) -> Result; + fn run(self, conn: &mut Connection) -> Result; } /// A single database migration. diff --git a/src/simple.rs b/src/simple.rs index 373c369..3eea3c1 100644 --- a/src/simple.rs +++ b/src/simple.rs @@ -52,7 +52,7 @@ impl SimpleVault { } /// Execute an [`Action`] and return the result. - pub fn execute(&mut self, action: A) -> Result { + pub fn execute(&mut self, action: A) -> Result { action.run(&mut self.0) } } diff --git a/src/tokio.rs b/src/tokio.rs index afb37d7..564f151 100644 --- a/src/tokio.rs +++ b/src/tokio.rs @@ -20,7 +20,7 @@ trait ActionWrapper { impl ActionWrapper for T where - T::Result: Send + 'static, + T::Output: Send + 'static, T::Error: Send + 'static, { fn run( @@ -133,10 +133,10 @@ impl TokioVault { } /// Execute an [`Action`] and return the result. - pub async fn execute(&self, action: A) -> Result> + pub async fn execute(&self, action: A) -> Result> where A: Action + Send + 'static, - A::Result: Send, + A::Output: Send, A::Error: Send, { let (tx, rx) = oneshot::channel(); @@ -153,7 +153,7 @@ impl TokioVault { // always work. match result { Ok(result) => { - let result = *result.downcast::().unwrap(); + let result = *result.downcast::().unwrap(); Ok(result) } Err(err) => {