commit eda19d28ffbbae8a840d514c7c8262892f2ebef2
parent 62671cb7652b265892429899c2e6fce53c1dc6e1
Author: triesap <tyson@radroots.org>
Date: Sat, 27 Jun 2026 08:22:03 +0000
events: derive dto events listing availability status delivery
Diffstat:
2 files changed, 13 insertions(+), 249 deletions(-)
diff --git a/crates/events/src/dto.rs b/crates/events/src/dto.rs
@@ -17,7 +17,7 @@ use crate::{
gcs::{RadrootsGcsLocation, RadrootsGeoJsonPoint, RadrootsGeoJsonPolygon},
geochat::RadrootsGeoChat,
gift_wrap::{RadrootsGiftWrap, RadrootsGiftWrapRecipient},
- ids::{RadrootsDTag, RadrootsInventoryBinId, RadrootsOrderQuoteId},
+ ids::{RadrootsInventoryBinId, RadrootsOrderQuoteId},
job::{JobFeedbackStatus, JobInputType, JobPaymentRequest},
job_feedback::RadrootsJobFeedback,
job_request::{RadrootsJobInput, RadrootsJobParam, RadrootsJobRequest},
@@ -175,253 +175,6 @@ pub struct RadrootsOrderStatusDto;
pub struct RadrootsOrderQuestionDto;
pub struct RadrootsCommercialTransportLaneDto;
-impl Dto for RadrootsListingAvailability {
- fn describe(ctx: &mut DescribeCtx) -> TypeRef {
- let def = EnumDef::new(
- "RadrootsListingAvailability",
- "RadrootsListingAvailability",
- EnumRepr::Adjacent {
- tag: "kind".to_owned(),
- content: "amount".to_owned(),
- },
- span("crates/events/src/listing.rs", 20),
- )
- .with_variant(VariantDef::new(
- "Window",
- "window",
- VariantShape::Struct(vec![
- optional_nullable_field(
- "start",
- "start",
- <Option<u64> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 21,
- )
- .with_int_repr(IntRepr::JsonString),
- optional_nullable_field(
- "end",
- "end",
- <Option<u64> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 22,
- )
- .with_int_repr(IntRepr::JsonString),
- ]),
- span("crates/events/src/listing.rs", 21),
- ))
- .with_variant(VariantDef::new(
- "Status",
- "status",
- VariantShape::Struct(vec![field(
- "status",
- "status",
- RadrootsListingStatus::describe(ctx),
- "crates/events/src/listing.rs",
- 24,
- )]),
- span("crates/events/src/listing.rs", 24),
- ));
- register(ctx, "RadrootsListingAvailability", TypeDef::Enum(def))
- }
-}
-
-impl Dto for RadrootsListingStatus {
- fn describe(ctx: &mut DescribeCtx) -> TypeRef {
- let def = EnumDef::new(
- "RadrootsListingStatus",
- "RadrootsListingStatus",
- EnumRepr::Adjacent {
- tag: "kind".to_owned(),
- content: "amount".to_owned(),
- },
- span("crates/events/src/listing.rs", 36),
- )
- .with_variant(VariantDef::new(
- "Active",
- "active",
- VariantShape::Unit,
- span("crates/events/src/listing.rs", 37),
- ))
- .with_variant(VariantDef::new(
- "Sold",
- "sold",
- VariantShape::Unit,
- span("crates/events/src/listing.rs", 38),
- ))
- .with_variant(VariantDef::new(
- "Other",
- "other",
- VariantShape::Struct(vec![field(
- "value",
- "value",
- String::describe(ctx),
- "crates/events/src/listing.rs",
- 39,
- )]),
- span("crates/events/src/listing.rs", 39),
- ));
- register(ctx, "RadrootsListingStatus", TypeDef::Enum(def))
- }
-}
-
-impl Dto for RadrootsListingDeliveryMethod {
- fn describe(ctx: &mut DescribeCtx) -> TypeRef {
- let def = EnumDef::new(
- "RadrootsListingDeliveryMethod",
- "RadrootsListingDeliveryMethod",
- EnumRepr::Adjacent {
- tag: "kind".to_owned(),
- content: "amount".to_owned(),
- },
- span("crates/events/src/listing.rs", 48),
- )
- .with_variant(VariantDef::new(
- "Pickup",
- "pickup",
- VariantShape::Unit,
- span("crates/events/src/listing.rs", 49),
- ))
- .with_variant(VariantDef::new(
- "LocalDelivery",
- "local_delivery",
- VariantShape::Unit,
- span("crates/events/src/listing.rs", 50),
- ))
- .with_variant(VariantDef::new(
- "Shipping",
- "shipping",
- VariantShape::Unit,
- span("crates/events/src/listing.rs", 51),
- ))
- .with_variant(VariantDef::new(
- "Other",
- "other",
- VariantShape::Struct(vec![field(
- "method",
- "method",
- String::describe(ctx),
- "crates/events/src/listing.rs",
- 52,
- )]),
- span("crates/events/src/listing.rs", 52),
- ));
- register(ctx, "RadrootsListingDeliveryMethod", TypeDef::Enum(def))
- }
-}
-
-impl Dto for RadrootsListing {
- fn describe(ctx: &mut DescribeCtx) -> TypeRef {
- let def = StructDef::new(
- "RadrootsListing",
- "RadrootsListing",
- span("crates/events/src/listing.rs", 57),
- )
- .with_field(field(
- "d_tag",
- "d_tag",
- RadrootsDTag::describe(ctx),
- "crates/events/src/listing.rs",
- 58,
- ))
- .with_field(
- optional_nullable_field(
- "published_at",
- "published_at",
- <Option<u64> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 63,
- )
- .with_presence(FieldPresence::optional_nullable_skip_if_none())
- .with_int_repr(IntRepr::JsonString),
- )
- .with_field(field(
- "farm",
- "farm",
- RadrootsFarmRef::describe(ctx),
- "crates/events/src/listing.rs",
- 68,
- ))
- .with_field(field(
- "product",
- "product",
- RadrootsListingProduct::describe(ctx),
- "crates/events/src/listing.rs",
- 69,
- ))
- .with_field(field(
- "primary_bin_id",
- "primary_bin_id",
- RadrootsInventoryBinId::describe(ctx),
- "crates/events/src/listing.rs",
- 70,
- ))
- .with_field(field(
- "bins",
- "bins",
- <Vec<RadrootsListingBin> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 71,
- ))
- .with_field(optional_nullable_field(
- "resource_area",
- "resource_area",
- <Option<RadrootsResourceAreaRef> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 72,
- ))
- .with_field(optional_nullable_field(
- "plot",
- "plot",
- <Option<RadrootsPlotRef> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 73,
- ))
- .with_field(optional_nullable_field(
- "discounts",
- "discounts",
- <Option<Vec<radroots_core::RadrootsCoreDiscount>> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 74,
- ))
- .with_field(optional_nullable_field(
- "inventory_available",
- "inventory_available",
- TypeRef::option(core_decimal(ctx)),
- "crates/events/src/listing.rs",
- 75,
- ))
- .with_field(optional_nullable_field(
- "availability",
- "availability",
- <Option<RadrootsListingAvailability> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 76,
- ))
- .with_field(optional_nullable_field(
- "delivery_method",
- "delivery_method",
- <Option<RadrootsListingDeliveryMethod> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 77,
- ))
- .with_field(optional_nullable_field(
- "location",
- "location",
- <Option<RadrootsListingPublicLocation> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 78,
- ))
- .with_field(optional_nullable_field(
- "images",
- "images",
- <Option<Vec<RadrootsListingImage>> as Dto>::describe(ctx),
- "crates/events/src/listing.rs",
- 79,
- ));
- register(ctx, "RadrootsListing", TypeDef::Struct(def))
- }
-}
-
impl Dto for RadrootsResourceHarvestCap {
fn describe(ctx: &mut DescribeCtx) -> TypeRef {
let def = StructDef::new(
diff --git a/crates/events/src/listing.rs b/crates/events/src/listing.rs
@@ -12,6 +12,8 @@ use crate::resource_area::RadrootsResourceAreaRef;
use alloc::{string::String, vec::Vec};
#[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(rename_all = "snake_case", tag = "kind", content = "amount")
@@ -19,7 +21,9 @@ use alloc::{string::String, vec::Vec};
#[derive(Clone, Debug)]
pub enum RadrootsListingAvailability {
Window {
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_string"))]
start: Option<u64>,
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_string"))]
end: Option<u64>,
},
Status {
@@ -28,6 +32,8 @@ pub enum RadrootsListingAvailability {
}
#[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(rename_all = "snake_case", tag = "kind", content = "amount")
@@ -40,6 +46,8 @@ pub enum RadrootsListingStatus {
}
#[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(rename_all = "snake_case", tag = "kind", content = "amount")
@@ -53,15 +61,18 @@ pub enum RadrootsListingDeliveryMethod {
}
#[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))]
#[derive(Clone, Debug)]
pub struct RadrootsListing {
pub d_tag: RadrootsDTag,
+ #[cfg_attr(feature = "dto-bindgen", dto(int = "json_string"))]
#[cfg_attr(
feature = "serde",
serde(default, skip_serializing_if = "Option::is_none")
)]
pub published_at: Option<u64>,
- #[cfg_attr(feature = "serde", serde(default))]
+ #[cfg_attr(all(feature = "serde", not(feature = "dto-bindgen")), serde(default))]
pub farm: RadrootsFarmRef,
pub product: RadrootsListingProduct,
pub primary_bin_id: RadrootsInventoryBinId,