balter icon indicating copy to clipboard operation
balter copied to clipboard

Make `#[transaction]` to work on functions not returning `Result<T, E>`

Open byronwasti opened this issue 10 months ago • 0 comments

Currently, #[transaction] can only be used on async functions which return a Result<T, E>. This let's Balter keep track of the error-rate.

#[transaction]
async fn foo() -> Result<(), Error> {
}

/// Error
#[transaction]
async fn bar() -> MyType {
}

However, certain transactions it might not make any sense to return a Result, and this becomes an unnecessary type restriction. Unfortunately I don't think this is trivial to support. If we have a #[transaction] be anything which returns impl TransactionOutput, then I think the options are limited:

  1. Users need to implement this on their types, which is annoying
  2. Opt-in to the specialization unstable feature, which I'd like to avoid (in order to special-case just Result)
  3. Expand the #[transaction] macro to do more code-gen to make this viable

From what I understand of the issue, (3) is the most viable.

byronwasti avatar Apr 17 '24 20:04 byronwasti