lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit c5e73d968eb8848d2ef0916528db0ae9d8a965c7
parent bc18a242474696bb6a3865bef43047c8a2168abb
Author: triesap <tyson@radroots.org>
Date:   Sat, 27 Jun 2026 08:27:07 +0000

events: derive dto events order workflow

Diffstat:
Mcrates/events/src/dto.rs | 92-------------------------------------------------------------------------------
Mcrates/events/src/order.rs | 18+++++++++++++++++-
2 files changed, 17 insertions(+), 93 deletions(-)

diff --git a/crates/events/src/dto.rs b/crates/events/src/dto.rs @@ -261,66 +261,6 @@ impl Dto for RadrootsResourceHarvestCap { } } -impl Dto for RadrootsListingParseError { - fn describe(ctx: &mut DescribeCtx) -> TypeRef { - let def = EnumDef::new( - "RadrootsListingParseError", - "RadrootsListingParseError", - EnumRepr::External, - span("crates/events/src/order.rs", 26), - ) - .with_variant(VariantDef::new( - "InvalidKind", - "InvalidKind", - VariantShape::Newtype(u32::describe(ctx)), - span("crates/events/src/order.rs", 27), - )) - .with_variant(VariantDef::new( - "MissingTag", - "MissingTag", - VariantShape::Newtype(String::describe(ctx)), - span("crates/events/src/order.rs", 28), - )) - .with_variant(VariantDef::new( - "InvalidTag", - "InvalidTag", - VariantShape::Newtype(String::describe(ctx)), - span("crates/events/src/order.rs", 29), - )) - .with_variant(VariantDef::new( - "InvalidNumber", - "InvalidNumber", - VariantShape::Newtype(String::describe(ctx)), - span("crates/events/src/order.rs", 30), - )) - .with_variant(VariantDef::new( - "InvalidUnit", - "InvalidUnit", - VariantShape::Unit, - span("crates/events/src/order.rs", 31), - )) - .with_variant(VariantDef::new( - "InvalidCurrency", - "InvalidCurrency", - VariantShape::Unit, - span("crates/events/src/order.rs", 32), - )) - .with_variant(VariantDef::new( - "InvalidJson", - "InvalidJson", - VariantShape::Newtype(String::describe(ctx)), - span("crates/events/src/order.rs", 33), - )) - .with_variant(VariantDef::new( - "InvalidDiscount", - "InvalidDiscount", - VariantShape::Newtype(String::describe(ctx)), - span("crates/events/src/order.rs", 34), - )); - register(ctx, "RadrootsListingParseError", TypeDef::Enum(def)) - } -} - impl Dto for RadrootsTradeValidationListingError { fn describe(ctx: &mut DescribeCtx) -> TypeRef { let parse_error = RadrootsListingParseError::describe(ctx); @@ -491,38 +431,6 @@ impl Dto for RadrootsTradeValidationListingError { } } -impl Dto for RadrootsOrderRevisionOutcome { - fn describe(ctx: &mut DescribeCtx) -> TypeRef { - let def = EnumDef::new( - "RadrootsOrderRevisionOutcome", - "RadrootsOrderRevisionOutcome", - EnumRepr::Internal { - tag: "decision".to_owned(), - }, - span("crates/events/src/order.rs", 221), - ) - .with_variant(VariantDef::new( - "Accepted", - "accepted", - VariantShape::Unit, - span("crates/events/src/order.rs", 222), - )) - .with_variant(VariantDef::new( - "Declined", - "declined", - VariantShape::Struct(vec![field( - "reason", - "reason", - String::describe(ctx), - "crates/events/src/order.rs", - 223, - )]), - span("crates/events/src/order.rs", 223), - )); - register(ctx, "RadrootsOrderRevisionOutcome", TypeDef::Enum(def)) - } -} - impl Dto for RadrootsOrderEnvelopeDto { fn describe(ctx: &mut DescribeCtx) -> TypeRef { let def = StructDef { diff --git a/crates/events/src/order.rs b/crates/events/src/order.rs @@ -22,6 +22,9 @@ pub const RADROOTS_COMMERCIAL_LISTING_DOMAIN: &str = "trade:listing"; pub const RADROOTS_ORDER_ENVELOPE_VERSION: u16 = 1; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] +#[cfg_attr(feature = "serde", serde(tag = "kind", content = "amount"))] #[derive(Clone, Debug, PartialEq, Eq)] pub enum RadrootsListingParseError { InvalidKind(u32), @@ -162,6 +165,7 @@ impl RadrootsOrderEconomics { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderRequest")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] @@ -187,6 +191,7 @@ impl RadrootsOrderRequest { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr( feature = "dto-bindgen", dto(ts(name = "RadrootsOrderRevisionProposal")) @@ -223,7 +228,12 @@ impl RadrootsOrderRevisionProposal { } #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "snake_case", tag = "decision"))] +#[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] +#[cfg_attr( + feature = "serde", + serde(rename_all = "snake_case", tag = "decision", content = "amount") +)] #[derive(Clone, Debug, PartialEq, Eq)] pub enum RadrootsOrderRevisionOutcome { Accepted, @@ -240,6 +250,7 @@ impl RadrootsOrderRevisionOutcome { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr( feature = "dto-bindgen", dto(ts(name = "RadrootsOrderRevisionDecision")) @@ -271,6 +282,7 @@ impl RadrootsOrderRevisionDecision { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr( feature = "dto-bindgen", dto(ts(name = "RadrootsOrderInventoryCommitment")) @@ -283,6 +295,7 @@ pub struct RadrootsOrderInventoryCommitment { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr( feature = "dto-bindgen", dto(ts(name = "RadrootsOrderDecisionOutcome")) @@ -311,6 +324,7 @@ impl RadrootsOrderDecisionOutcome { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderDecision")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] @@ -333,6 +347,7 @@ impl RadrootsOrderDecision { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderCancellation")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq)] @@ -355,6 +370,7 @@ impl RadrootsOrderCancellation { } #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))] +#[cfg_attr(feature = "dto-bindgen", dto(export))] #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsCommercialDomain")))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]