Rename Action::Result to Action::Output
This commit is contained in:
parent
2bf19e0ea2
commit
742bd158f1
4 changed files with 8 additions and 7 deletions
|
|
@ -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<Self::Result, Self::Error>;
|
||||
fn run(self, conn: &mut Connection) -> Result<Self::Output, Self::Error>;
|
||||
}
|
||||
|
||||
/// A single database migration.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ impl SimpleVault {
|
|||
}
|
||||
|
||||
/// Execute an [`Action`] and return the result.
|
||||
pub fn execute<A: Action>(&mut self, action: A) -> Result<A::Result, A::Error> {
|
||||
pub fn execute<A: Action>(&mut self, action: A) -> Result<A::Output, A::Error> {
|
||||
action.run(&mut self.0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ trait ActionWrapper {
|
|||
|
||||
impl<T: Action> 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<A>(&self, action: A) -> Result<A::Result, Error<A::Error>>
|
||||
pub async fn execute<A>(&self, action: A) -> Result<A::Output, Error<A::Error>>
|
||||
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::<A::Result>().unwrap();
|
||||
let result = *result.downcast::<A::Output>().unwrap();
|
||||
Ok(result)
|
||||
}
|
||||
Err(err) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue