Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standards and utilities for wrapping and unwrapping the aggregate constraint checker onion #118

Open
JoshOrndorff opened this issue Oct 11, 2023 · 0 comments

Comments

@JoshOrndorff
Copy link
Contributor

A typical Tuxedo runtime is aggregated from individual pieces. This aggregation may even be recursive if #116 works out).

It is common that you need to convert between an inner and outer constraint checker or vise versa. The aggregation macro automatically implements From<inner> for Outer but there is no convenient way to go from outer to inner. One idea is to have the macro implement methods like this.

// This is an expansion of what would be macro-generated code.
// I've elided the generic verifier for simplicity.
pub enum OuterConstraintChecker {
  Money(money::Money),
  Amoeba(amoeba::Amoeba),
}

// An assumption about both directions of conversion is that each
// constituent constraint checker is a unique type.

// These impls for wrapping layers onto the onion already exist.
impl From(money::Money) for OuterConstraintChecker { ... }
impl From(amoeba::Amoeba) for OuterConstraintChecker { ... }

// These ones could be added
impl From<OuterConstraintChecker> for money::Money { ... }
impl From<OuterConstraintChecker> for amoeba::Amoeba { ... }

A related issue is transforming a Transaction<OuterConstraintChecker> into a Transaction<InnerConstraintChecker> of vise versa. @muraca has given the idea of a transform method in 42f475c#diff-41e8e33684d0c2b86e827e306c10a1ce0787a681d8d9caf9191f178c09dfbe5eR23-R32 Previously I could only make that method work for wrapping the onion, but I think with the new From impls it would work both directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant