diff --git a/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/embed/external.rs b/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/embed/external.rs index ebfa7afc..631b1597 100644 --- a/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/embed/external.rs +++ b/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/embed/external.rs @@ -233,50 +233,50 @@ pub mod external_state { /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Uri; - type Title; type Description; + type Title; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Uri = Unset; - type Title = Unset; type Description = Unset; + type Title = Unset; } ///State transition - sets the `uri` field to Set pub struct SetUri(PhantomData St>); impl sealed::Sealed for SetUri {} impl State for SetUri { type Uri = Set; - type Title = St::Title; - type Description = St::Description; - } - ///State transition - sets the `title` field to Set - pub struct SetTitle(PhantomData St>); - impl sealed::Sealed for SetTitle {} - impl State for SetTitle { - type Uri = St::Uri; - type Title = Set; type Description = St::Description; + type Title = St::Title; } ///State transition - sets the `description` field to Set pub struct SetDescription(PhantomData St>); impl sealed::Sealed for SetDescription {} impl State for SetDescription { type Uri = St::Uri; - type Title = St::Title; type Description = Set; + type Title = St::Title; + } + ///State transition - sets the `title` field to Set + pub struct SetTitle(PhantomData St>); + impl sealed::Sealed for SetTitle {} + impl State for SetTitle { + type Uri = St::Uri; + type Description = St::Description; + type Title = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `uri` field pub struct uri(()); - ///Marker type for the `title` field - pub struct title(()); ///Marker type for the `description` field pub struct description(()); + ///Marker type for the `title` field + pub struct title(()); } } @@ -390,8 +390,8 @@ impl ExternalBuilder where St: external_state::State, St::Uri: external_state::IsSet, - St::Title: external_state::IsSet, St::Description: external_state::IsSet, + St::Title: external_state::IsSet, { /// Build the final struct. pub fn build(self) -> External { @@ -827,50 +827,50 @@ pub mod view_external_state { /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Title; - type Uri; type Description; + type Uri; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Title = Unset; - type Uri = Unset; type Description = Unset; + type Uri = Unset; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData St>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { type Title = Set; - type Uri = St::Uri; - type Description = St::Description; - } - ///State transition - sets the `uri` field to Set - pub struct SetUri(PhantomData St>); - impl sealed::Sealed for SetUri {} - impl State for SetUri { - type Title = St::Title; - type Uri = Set; type Description = St::Description; + type Uri = St::Uri; } ///State transition - sets the `description` field to Set pub struct SetDescription(PhantomData St>); impl sealed::Sealed for SetDescription {} impl State for SetDescription { type Title = St::Title; - type Uri = St::Uri; type Description = Set; + type Uri = St::Uri; + } + ///State transition - sets the `uri` field to Set + pub struct SetUri(PhantomData St>); + impl sealed::Sealed for SetUri {} + impl State for SetUri { + type Title = St::Title; + type Description = St::Description; + type Uri = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `title` field pub struct title(()); - ///Marker type for the `uri` field - pub struct uri(()); ///Marker type for the `description` field pub struct description(()); + ///Marker type for the `uri` field + pub struct uri(()); } } @@ -990,8 +990,8 @@ impl ViewExternalBuilder where St: view_external_state::State, St::Title: view_external_state::IsSet, - St::Uri: view_external_state::IsSet, St::Description: view_external_state::IsSet, + St::Uri: view_external_state::IsSet, { /// Build the final struct. pub fn build(self) -> ViewExternal { diff --git a/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/richtext/facet.rs b/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/richtext/facet.rs index 0b2d5680..1cd60368 100644 --- a/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/richtext/facet.rs +++ b/crates/jacquard-codegen-tests/src/generated/macro_mode/app_bsky/richtext/facet.rs @@ -310,37 +310,37 @@ pub mod byte_slice_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type ByteEnd; type ByteStart; + type ByteEnd; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type ByteEnd = Unset; type ByteStart = Unset; - } - ///State transition - sets the `byte_end` field to Set - pub struct SetByteEnd(PhantomData St>); - impl sealed::Sealed for SetByteEnd {} - impl State for SetByteEnd { - type ByteEnd = Set; - type ByteStart = St::ByteStart; + type ByteEnd = Unset; } ///State transition - sets the `byte_start` field to Set pub struct SetByteStart(PhantomData St>); impl sealed::Sealed for SetByteStart {} impl State for SetByteStart { - type ByteEnd = St::ByteEnd; type ByteStart = Set; + type ByteEnd = St::ByteEnd; + } + ///State transition - sets the `byte_end` field to Set + pub struct SetByteEnd(PhantomData St>); + impl sealed::Sealed for SetByteEnd {} + impl State for SetByteEnd { + type ByteStart = St::ByteStart; + type ByteEnd = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `byte_end` field - pub struct byte_end(()); ///Marker type for the `byte_start` field pub struct byte_start(()); + ///Marker type for the `byte_end` field + pub struct byte_end(()); } } @@ -410,8 +410,8 @@ where impl ByteSliceBuilder where St: byte_slice_state::State, - St::ByteEnd: byte_slice_state::IsSet, St::ByteStart: byte_slice_state::IsSet, + St::ByteEnd: byte_slice_state::IsSet, { /// Build the final struct. pub fn build(self) -> ByteSlice { @@ -746,37 +746,37 @@ pub mod facet_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Features; type Index; + type Features; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Features = Unset; type Index = Unset; - } - ///State transition - sets the `features` field to Set - pub struct SetFeatures(PhantomData St>); - impl sealed::Sealed for SetFeatures {} - impl State for SetFeatures { - type Features = Set; - type Index = St::Index; + type Features = Unset; } ///State transition - sets the `index` field to Set pub struct SetIndex(PhantomData St>); impl sealed::Sealed for SetIndex {} impl State for SetIndex { - type Features = St::Features; type Index = Set; + type Features = St::Features; + } + ///State transition - sets the `features` field to Set + pub struct SetFeatures(PhantomData St>); + impl sealed::Sealed for SetFeatures {} + impl State for SetFeatures { + type Index = St::Index; + type Features = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `features` field - pub struct features(()); ///Marker type for the `index` field pub struct index(()); + ///Marker type for the `features` field + pub struct features(()); } } @@ -849,8 +849,8 @@ where impl FacetBuilder where St: facet_state::State, - St::Features: facet_state::IsSet, St::Index: facet_state::IsSet, + St::Features: facet_state::IsSet, { /// Build the final struct. pub fn build(self) -> Facet { diff --git a/crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/label.rs b/crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/label.rs index 1800f142..3a4d0604 100644 --- a/crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/label.rs +++ b/crates/jacquard-codegen-tests/src/generated/macro_mode/com_atproto/label.rs @@ -797,67 +797,67 @@ pub mod label_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { + type Val; type Cts; type Uri; type Src; - type Val; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { + type Val = Unset; type Cts = Unset; type Uri = Unset; type Src = Unset; - type Val = Unset; + } + ///State transition - sets the `val` field to Set + pub struct SetVal(PhantomData St>); + impl sealed::Sealed for SetVal {} + impl State for SetVal { + type Val = Set; + type Cts = St::Cts; + type Uri = St::Uri; + type Src = St::Src; } ///State transition - sets the `cts` field to Set pub struct SetCts(PhantomData St>); impl sealed::Sealed for SetCts {} impl State for SetCts { + type Val = St::Val; type Cts = Set; type Uri = St::Uri; type Src = St::Src; - type Val = St::Val; } ///State transition - sets the `uri` field to Set pub struct SetUri(PhantomData St>); impl sealed::Sealed for SetUri {} impl State for SetUri { + type Val = St::Val; type Cts = St::Cts; type Uri = Set; type Src = St::Src; - type Val = St::Val; } ///State transition - sets the `src` field to Set pub struct SetSrc(PhantomData St>); impl sealed::Sealed for SetSrc {} impl State for SetSrc { - type Cts = St::Cts; - type Uri = St::Uri; - type Src = Set; type Val = St::Val; - } - ///State transition - sets the `val` field to Set - pub struct SetVal(PhantomData St>); - impl sealed::Sealed for SetVal {} - impl State for SetVal { type Cts = St::Cts; type Uri = St::Uri; - type Src = St::Src; - type Val = Set; + type Src = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { + ///Marker type for the `val` field + pub struct val(()); ///Marker type for the `cts` field pub struct cts(()); ///Marker type for the `uri` field pub struct uri(()); ///Marker type for the `src` field pub struct src(()); - ///Marker type for the `val` field - pub struct val(()); } } @@ -1058,10 +1058,10 @@ impl LabelBuilder { impl LabelBuilder where St: label_state::State, + St::Val: label_state::IsSet, St::Cts: label_state::IsSet, St::Uri: label_state::IsSet, St::Src: label_state::IsSet, - St::Val: label_state::IsSet, { /// Build the final struct. pub fn build(self) -> Label { @@ -1515,67 +1515,67 @@ pub mod label_value_definition_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { + type Identifier; + type Blurs; type Locales; type Severity; - type Blurs; - type Identifier; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { + type Identifier = Unset; + type Blurs = Unset; type Locales = Unset; type Severity = Unset; - type Blurs = Unset; - type Identifier = Unset; + } + ///State transition - sets the `identifier` field to Set + pub struct SetIdentifier(PhantomData St>); + impl sealed::Sealed for SetIdentifier {} + impl State for SetIdentifier { + type Identifier = Set; + type Blurs = St::Blurs; + type Locales = St::Locales; + type Severity = St::Severity; + } + ///State transition - sets the `blurs` field to Set + pub struct SetBlurs(PhantomData St>); + impl sealed::Sealed for SetBlurs {} + impl State for SetBlurs { + type Identifier = St::Identifier; + type Blurs = Set; + type Locales = St::Locales; + type Severity = St::Severity; } ///State transition - sets the `locales` field to Set pub struct SetLocales(PhantomData St>); impl sealed::Sealed for SetLocales {} impl State for SetLocales { + type Identifier = St::Identifier; + type Blurs = St::Blurs; type Locales = Set; type Severity = St::Severity; - type Blurs = St::Blurs; - type Identifier = St::Identifier; } ///State transition - sets the `severity` field to Set pub struct SetSeverity(PhantomData St>); impl sealed::Sealed for SetSeverity {} impl State for SetSeverity { - type Locales = St::Locales; - type Severity = Set; - type Blurs = St::Blurs; - type Identifier = St::Identifier; - } - ///State transition - sets the `blurs` field to Set - pub struct SetBlurs(PhantomData St>); - impl sealed::Sealed for SetBlurs {} - impl State for SetBlurs { - type Locales = St::Locales; - type Severity = St::Severity; - type Blurs = Set; type Identifier = St::Identifier; - } - ///State transition - sets the `identifier` field to Set - pub struct SetIdentifier(PhantomData St>); - impl sealed::Sealed for SetIdentifier {} - impl State for SetIdentifier { - type Locales = St::Locales; - type Severity = St::Severity; type Blurs = St::Blurs; - type Identifier = Set; + type Locales = St::Locales; + type Severity = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { + ///Marker type for the `identifier` field + pub struct identifier(()); + ///Marker type for the `blurs` field + pub struct blurs(()); ///Marker type for the `locales` field pub struct locales(()); ///Marker type for the `severity` field pub struct severity(()); - ///Marker type for the `blurs` field - pub struct blurs(()); - ///Marker type for the `identifier` field - pub struct identifier(()); } } @@ -1740,10 +1740,10 @@ where impl LabelValueDefinitionBuilder where St: label_value_definition_state::State, + St::Identifier: label_value_definition_state::IsSet, + St::Blurs: label_value_definition_state::IsSet, St::Locales: label_value_definition_state::IsSet, St::Severity: label_value_definition_state::IsSet, - St::Blurs: label_value_definition_state::IsSet, - St::Identifier: label_value_definition_state::IsSet, { /// Build the final struct. pub fn build(self) -> LabelValueDefinition { @@ -1787,49 +1787,49 @@ pub mod label_value_definition_strings_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Lang; type Name; + type Lang; type Description; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Lang = Unset; type Name = Unset; + type Lang = Unset; type Description = Unset; } - ///State transition - sets the `lang` field to Set - pub struct SetLang(PhantomData St>); - impl sealed::Sealed for SetLang {} - impl State for SetLang { - type Lang = Set; - type Name = St::Name; - type Description = St::Description; - } ///State transition - sets the `name` field to Set pub struct SetName(PhantomData St>); impl sealed::Sealed for SetName {} impl State for SetName { - type Lang = St::Lang; type Name = Set; + type Lang = St::Lang; + type Description = St::Description; + } + ///State transition - sets the `lang` field to Set + pub struct SetLang(PhantomData St>); + impl sealed::Sealed for SetLang {} + impl State for SetLang { + type Name = St::Name; + type Lang = Set; type Description = St::Description; } ///State transition - sets the `description` field to Set pub struct SetDescription(PhantomData St>); impl sealed::Sealed for SetDescription {} impl State for SetDescription { - type Lang = St::Lang; type Name = St::Name; + type Lang = St::Lang; type Description = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `lang` field - pub struct lang(()); ///Marker type for the `name` field pub struct name(()); + ///Marker type for the `lang` field + pub struct lang(()); ///Marker type for the `description` field pub struct description(()); } @@ -1941,8 +1941,8 @@ where impl LabelValueDefinitionStringsBuilder where St: label_value_definition_strings_state::State, - St::Lang: label_value_definition_strings_state::IsSet, St::Name: label_value_definition_strings_state::IsSet, + St::Lang: label_value_definition_strings_state::IsSet, St::Description: label_value_definition_strings_state::IsSet, { /// Build the final struct. diff --git a/crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns3/collision.rs b/crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns3/collision.rs index 5e7b29b7..518292d3 100644 --- a/crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns3/collision.rs +++ b/crates/jacquard-codegen-tests/src/generated/macro_mode/test_ns3/collision.rs @@ -335,37 +335,37 @@ pub mod collision_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type LocalFoo; type ExternalFoo; + type LocalFoo; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type LocalFoo = Unset; type ExternalFoo = Unset; - } - ///State transition - sets the `local_foo` field to Set - pub struct SetLocalFoo(PhantomData St>); - impl sealed::Sealed for SetLocalFoo {} - impl State for SetLocalFoo { - type LocalFoo = Set; - type ExternalFoo = St::ExternalFoo; + type LocalFoo = Unset; } ///State transition - sets the `external_foo` field to Set pub struct SetExternalFoo(PhantomData St>); impl sealed::Sealed for SetExternalFoo {} impl State for SetExternalFoo { - type LocalFoo = St::LocalFoo; type ExternalFoo = Set; + type LocalFoo = St::LocalFoo; + } + ///State transition - sets the `local_foo` field to Set + pub struct SetLocalFoo(PhantomData St>); + impl sealed::Sealed for SetLocalFoo {} + impl State for SetLocalFoo { + type ExternalFoo = St::ExternalFoo; + type LocalFoo = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `local_foo` field - pub struct local_foo(()); ///Marker type for the `external_foo` field pub struct external_foo(()); + ///Marker type for the `local_foo` field + pub struct local_foo(()); } } @@ -452,8 +452,8 @@ impl CollisionBuilder CollisionBuilder where St: collision_state::State, - St::LocalFoo: collision_state::IsSet, St::ExternalFoo: collision_state::IsSet, + St::LocalFoo: collision_state::IsSet, { /// Build the final struct. pub fn build(self) -> Collision { diff --git a/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/embed/external.rs b/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/embed/external.rs index 90f8a18b..33c1b12c 100644 --- a/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/embed/external.rs +++ b/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/embed/external.rs @@ -179,51 +179,51 @@ pub mod external_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { + type Uri; type Title; type Description; - type Uri; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { + type Uri = Unset; type Title = Unset; type Description = Unset; - type Uri = Unset; + } + ///State transition - sets the `uri` field to Set + pub struct SetUri(PhantomData St>); + impl sealed::Sealed for SetUri {} + impl State for SetUri { + type Uri = Set; + type Title = St::Title; + type Description = St::Description; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData St>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { + type Uri = St::Uri; type Title = Set; type Description = St::Description; - type Uri = St::Uri; } ///State transition - sets the `description` field to Set pub struct SetDescription(PhantomData St>); impl sealed::Sealed for SetDescription {} impl State for SetDescription { - type Title = St::Title; - type Description = Set; type Uri = St::Uri; - } - ///State transition - sets the `uri` field to Set - pub struct SetUri(PhantomData St>); - impl sealed::Sealed for SetUri {} - impl State for SetUri { type Title = St::Title; - type Description = St::Description; - type Uri = Set; + type Description = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { + ///Marker type for the `uri` field + pub struct uri(()); ///Marker type for the `title` field pub struct title(()); ///Marker type for the `description` field pub struct description(()); - ///Marker type for the `uri` field - pub struct uri(()); } } @@ -325,9 +325,9 @@ where impl ExternalBuilder where St: external_state::State, + St::Uri: external_state::IsSet, St::Title: external_state::IsSet, St::Description: external_state::IsSet, - St::Uri: external_state::IsSet, { /// Build the final struct. pub fn build(self) -> External { @@ -692,51 +692,51 @@ pub mod view_external_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Uri; type Title; type Description; + type Uri; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Uri = Unset; type Title = Unset; type Description = Unset; - } - ///State transition - sets the `uri` field to Set - pub struct SetUri(PhantomData St>); - impl sealed::Sealed for SetUri {} - impl State for SetUri { - type Uri = Set; - type Title = St::Title; - type Description = St::Description; + type Uri = Unset; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData St>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { - type Uri = St::Uri; type Title = Set; type Description = St::Description; + type Uri = St::Uri; } ///State transition - sets the `description` field to Set pub struct SetDescription(PhantomData St>); impl sealed::Sealed for SetDescription {} impl State for SetDescription { - type Uri = St::Uri; type Title = St::Title; type Description = Set; + type Uri = St::Uri; + } + ///State transition - sets the `uri` field to Set + pub struct SetUri(PhantomData St>); + impl sealed::Sealed for SetUri {} + impl State for SetUri { + type Title = St::Title; + type Description = St::Description; + type Uri = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `uri` field - pub struct uri(()); ///Marker type for the `title` field pub struct title(()); ///Marker type for the `description` field pub struct description(()); + ///Marker type for the `uri` field + pub struct uri(()); } } @@ -838,9 +838,9 @@ where impl ViewExternalBuilder where St: view_external_state::State, - St::Uri: view_external_state::IsSet, St::Title: view_external_state::IsSet, St::Description: view_external_state::IsSet, + St::Uri: view_external_state::IsSet, { /// Build the final struct. pub fn build(self) -> ViewExternal { diff --git a/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/richtext/facet.rs b/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/richtext/facet.rs index ca07f0f4..b526fd91 100644 --- a/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/richtext/facet.rs +++ b/crates/jacquard-codegen-tests/src/generated/pretty/app_bsky/richtext/facet.rs @@ -616,37 +616,37 @@ pub mod facet_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Index; type Features; + type Index; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Index = Unset; type Features = Unset; - } - ///State transition - sets the `index` field to Set - pub struct SetIndex(PhantomData St>); - impl sealed::Sealed for SetIndex {} - impl State for SetIndex { - type Index = Set; - type Features = St::Features; + type Index = Unset; } ///State transition - sets the `features` field to Set pub struct SetFeatures(PhantomData St>); impl sealed::Sealed for SetFeatures {} impl State for SetFeatures { - type Index = St::Index; type Features = Set; + type Index = St::Index; + } + ///State transition - sets the `index` field to Set + pub struct SetIndex(PhantomData St>); + impl sealed::Sealed for SetIndex {} + impl State for SetIndex { + type Features = St::Features; + type Index = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `index` field - pub struct index(()); ///Marker type for the `features` field pub struct features(()); + ///Marker type for the `index` field + pub struct index(()); } } @@ -716,8 +716,8 @@ where impl FacetBuilder where St: facet_state::State, - St::Index: facet_state::IsSet, St::Features: facet_state::IsSet, + St::Index: facet_state::IsSet, { /// Build the final struct. pub fn build(self) -> Facet { diff --git a/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/label.rs b/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/label.rs index 852614ef..e2f634a7 100644 --- a/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/label.rs +++ b/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/label.rs @@ -680,66 +680,66 @@ pub mod label_state { /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Src; - type Cts; - type Uri; type Val; + type Uri; + type Cts; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Src = Unset; - type Cts = Unset; - type Uri = Unset; type Val = Unset; + type Uri = Unset; + type Cts = Unset; } ///State transition - sets the `src` field to Set pub struct SetSrc(PhantomData St>); impl sealed::Sealed for SetSrc {} impl State for SetSrc { type Src = Set; - type Cts = St::Cts; - type Uri = St::Uri; type Val = St::Val; + type Uri = St::Uri; + type Cts = St::Cts; } - ///State transition - sets the `cts` field to Set - pub struct SetCts(PhantomData St>); - impl sealed::Sealed for SetCts {} - impl State for SetCts { + ///State transition - sets the `val` field to Set + pub struct SetVal(PhantomData St>); + impl sealed::Sealed for SetVal {} + impl State for SetVal { type Src = St::Src; - type Cts = Set; + type Val = Set; type Uri = St::Uri; - type Val = St::Val; + type Cts = St::Cts; } ///State transition - sets the `uri` field to Set pub struct SetUri(PhantomData St>); impl sealed::Sealed for SetUri {} impl State for SetUri { type Src = St::Src; - type Cts = St::Cts; - type Uri = Set; type Val = St::Val; + type Uri = Set; + type Cts = St::Cts; } - ///State transition - sets the `val` field to Set - pub struct SetVal(PhantomData St>); - impl sealed::Sealed for SetVal {} - impl State for SetVal { + ///State transition - sets the `cts` field to Set + pub struct SetCts(PhantomData St>); + impl sealed::Sealed for SetCts {} + impl State for SetCts { type Src = St::Src; - type Cts = St::Cts; + type Val = St::Val; type Uri = St::Uri; - type Val = Set; + type Cts = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `src` field pub struct src(()); - ///Marker type for the `cts` field - pub struct cts(()); - ///Marker type for the `uri` field - pub struct uri(()); ///Marker type for the `val` field pub struct val(()); + ///Marker type for the `uri` field + pub struct uri(()); + ///Marker type for the `cts` field + pub struct cts(()); } } @@ -923,9 +923,9 @@ impl LabelBuilder where St: label_state::State, St::Src: label_state::IsSet, - St::Cts: label_state::IsSet, - St::Uri: label_state::IsSet, St::Val: label_state::IsSet, + St::Uri: label_state::IsSet, + St::Cts: label_state::IsSet, { /// Build the final struct. pub fn build(self) -> Label { @@ -1297,67 +1297,67 @@ pub mod label_value_definition_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Identifier; + type Blurs; type Locales; type Severity; - type Blurs; + type Identifier; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Identifier = Unset; + type Blurs = Unset; type Locales = Unset; type Severity = Unset; - type Blurs = Unset; + type Identifier = Unset; } - ///State transition - sets the `identifier` field to Set - pub struct SetIdentifier(PhantomData St>); - impl sealed::Sealed for SetIdentifier {} - impl State for SetIdentifier { - type Identifier = Set; + ///State transition - sets the `blurs` field to Set + pub struct SetBlurs(PhantomData St>); + impl sealed::Sealed for SetBlurs {} + impl State for SetBlurs { + type Blurs = Set; type Locales = St::Locales; type Severity = St::Severity; - type Blurs = St::Blurs; + type Identifier = St::Identifier; } ///State transition - sets the `locales` field to Set pub struct SetLocales(PhantomData St>); impl sealed::Sealed for SetLocales {} impl State for SetLocales { - type Identifier = St::Identifier; + type Blurs = St::Blurs; type Locales = Set; type Severity = St::Severity; - type Blurs = St::Blurs; + type Identifier = St::Identifier; } ///State transition - sets the `severity` field to Set pub struct SetSeverity(PhantomData St>); impl sealed::Sealed for SetSeverity {} impl State for SetSeverity { - type Identifier = St::Identifier; + type Blurs = St::Blurs; type Locales = St::Locales; type Severity = Set; - type Blurs = St::Blurs; - } - ///State transition - sets the `blurs` field to Set - pub struct SetBlurs(PhantomData St>); - impl sealed::Sealed for SetBlurs {} - impl State for SetBlurs { type Identifier = St::Identifier; + } + ///State transition - sets the `identifier` field to Set + pub struct SetIdentifier(PhantomData St>); + impl sealed::Sealed for SetIdentifier {} + impl State for SetIdentifier { + type Blurs = St::Blurs; type Locales = St::Locales; type Severity = St::Severity; - type Blurs = Set; + type Identifier = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `identifier` field - pub struct identifier(()); + ///Marker type for the `blurs` field + pub struct blurs(()); ///Marker type for the `locales` field pub struct locales(()); ///Marker type for the `severity` field pub struct severity(()); - ///Marker type for the `blurs` field - pub struct blurs(()); + ///Marker type for the `identifier` field + pub struct identifier(()); } } @@ -1516,10 +1516,10 @@ where impl LabelValueDefinitionBuilder where St: label_value_definition_state::State, - St::Identifier: label_value_definition_state::IsSet, + St::Blurs: label_value_definition_state::IsSet, St::Locales: label_value_definition_state::IsSet, St::Severity: label_value_definition_state::IsSet, - St::Blurs: label_value_definition_state::IsSet, + St::Identifier: label_value_definition_state::IsSet, { /// Build the final struct. pub fn build(self) -> LabelValueDefinition { @@ -1560,51 +1560,51 @@ pub mod label_value_definition_strings_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Description; - type Lang; type Name; + type Lang; + type Description; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Description = Unset; - type Lang = Unset; type Name = Unset; + type Lang = Unset; + type Description = Unset; } - ///State transition - sets the `description` field to Set - pub struct SetDescription(PhantomData St>); - impl sealed::Sealed for SetDescription {} - impl State for SetDescription { - type Description = Set; + ///State transition - sets the `name` field to Set + pub struct SetName(PhantomData St>); + impl sealed::Sealed for SetName {} + impl State for SetName { + type Name = Set; type Lang = St::Lang; - type Name = St::Name; + type Description = St::Description; } ///State transition - sets the `lang` field to Set pub struct SetLang(PhantomData St>); impl sealed::Sealed for SetLang {} impl State for SetLang { - type Description = St::Description; - type Lang = Set; type Name = St::Name; - } - ///State transition - sets the `name` field to Set - pub struct SetName(PhantomData St>); - impl sealed::Sealed for SetName {} - impl State for SetName { + type Lang = Set; type Description = St::Description; + } + ///State transition - sets the `description` field to Set + pub struct SetDescription(PhantomData St>); + impl sealed::Sealed for SetDescription {} + impl State for SetDescription { + type Name = St::Name; type Lang = St::Lang; - type Name = Set; + type Description = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `description` field - pub struct description(()); - ///Marker type for the `lang` field - pub struct lang(()); ///Marker type for the `name` field pub struct name(()); + ///Marker type for the `lang` field + pub struct lang(()); + ///Marker type for the `description` field + pub struct description(()); } } @@ -1710,9 +1710,9 @@ where impl LabelValueDefinitionStringsBuilder where St: label_value_definition_strings_state::State, - St::Description: label_value_definition_strings_state::IsSet, - St::Lang: label_value_definition_strings_state::IsSet, St::Name: label_value_definition_strings_state::IsSet, + St::Lang: label_value_definition_strings_state::IsSet, + St::Description: label_value_definition_strings_state::IsSet, { /// Build the final struct. pub fn build(self) -> LabelValueDefinitionStrings { diff --git a/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/repo/strong_ref.rs b/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/repo/strong_ref.rs index 8b7c0d75..21e9e024 100644 --- a/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/repo/strong_ref.rs +++ b/crates/jacquard-codegen-tests/src/generated/pretty/com_atproto/repo/strong_ref.rs @@ -59,37 +59,37 @@ pub mod strong_ref_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Uri; type Cid; + type Uri; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Uri = Unset; type Cid = Unset; - } - ///State transition - sets the `uri` field to Set - pub struct SetUri(PhantomData St>); - impl sealed::Sealed for SetUri {} - impl State for SetUri { - type Uri = Set; - type Cid = St::Cid; + type Uri = Unset; } ///State transition - sets the `cid` field to Set pub struct SetCid(PhantomData St>); impl sealed::Sealed for SetCid {} impl State for SetCid { - type Uri = St::Uri; type Cid = Set; + type Uri = St::Uri; + } + ///State transition - sets the `uri` field to Set + pub struct SetUri(PhantomData St>); + impl sealed::Sealed for SetUri {} + impl State for SetUri { + type Cid = St::Cid; + type Uri = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `uri` field - pub struct uri(()); ///Marker type for the `cid` field pub struct cid(()); + ///Marker type for the `uri` field + pub struct uri(()); } } @@ -159,8 +159,8 @@ where impl StrongRefBuilder where St: strong_ref_state::State, - St::Uri: strong_ref_state::IsSet, St::Cid: strong_ref_state::IsSet, + St::Uri: strong_ref_state::IsSet, { /// Build the final struct. pub fn build(self) -> StrongRef { diff --git a/crates/jacquard-codegen-tests/src/generated/pretty/test_ns3/collision.rs b/crates/jacquard-codegen-tests/src/generated/pretty/test_ns3/collision.rs index 2ca16dec..3e6e762a 100644 --- a/crates/jacquard-codegen-tests/src/generated/pretty/test_ns3/collision.rs +++ b/crates/jacquard-codegen-tests/src/generated/pretty/test_ns3/collision.rs @@ -298,37 +298,37 @@ pub mod collision_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type ExternalFoo; type LocalFoo; + type ExternalFoo; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type ExternalFoo = Unset; type LocalFoo = Unset; - } - ///State transition - sets the `external_foo` field to Set - pub struct SetExternalFoo(PhantomData St>); - impl sealed::Sealed for SetExternalFoo {} - impl State for SetExternalFoo { - type ExternalFoo = Set; - type LocalFoo = St::LocalFoo; + type ExternalFoo = Unset; } ///State transition - sets the `local_foo` field to Set pub struct SetLocalFoo(PhantomData St>); impl sealed::Sealed for SetLocalFoo {} impl State for SetLocalFoo { - type ExternalFoo = St::ExternalFoo; type LocalFoo = Set; + type ExternalFoo = St::ExternalFoo; + } + ///State transition - sets the `external_foo` field to Set + pub struct SetExternalFoo(PhantomData St>); + impl sealed::Sealed for SetExternalFoo {} + impl State for SetExternalFoo { + type LocalFoo = St::LocalFoo; + type ExternalFoo = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `external_foo` field - pub struct external_foo(()); ///Marker type for the `local_foo` field pub struct local_foo(()); + ///Marker type for the `external_foo` field + pub struct external_foo(()); } } @@ -411,8 +411,8 @@ impl CollisionBuilder { impl CollisionBuilder where St: collision_state::State, - St::ExternalFoo: collision_state::IsSet, St::LocalFoo: collision_state::IsSet, + St::ExternalFoo: collision_state::IsSet, { /// Build the final struct. pub fn build(self) -> Collision { diff --git a/crates/jacquard-identity/Cargo.toml b/crates/jacquard-identity/Cargo.toml index 27eafbe7..38475aa8 100644 --- a/crates/jacquard-identity/Cargo.toml +++ b/crates/jacquard-identity/Cargo.toml @@ -41,8 +41,7 @@ hickory-resolver = { optional = true, version = "0.24", default-features = false tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } -[target.'cfg(target_arch = "wasm32")'.dependencies] -mini-moka = { package = "mini-moka-wasm", version = "0.10",path = "../mini-moka-wasm", features = ["js"], optional = true } + #ring = { version = "0.17", default-features = false, features = ["wasm32_unknown_unknown_js"]} [[example]] diff --git a/crates/jacquard-identity/src/lib.rs b/crates/jacquard-identity/src/lib.rs index cd95e897..043f3c6c 100644 --- a/crates/jacquard-identity/src/lib.rs +++ b/crates/jacquard-identity/src/lib.rs @@ -647,12 +647,12 @@ impl JacquardResolver { .unwrap_or_default(); let url_str = if qs.is_empty() { format!( - "{}xrpc/com.bad-example.identity.resolveMiniDoc", + "{}xrpc/blue.microcosm.identity.resolveMiniDoc", base.as_str().trim_end_matches('/').to_string() + "/" ) } else { format!( - "{}xrpc/com.bad-example.identity.resolveMiniDoc?{}", + "{}xrpc/blue.microcosm.identity.resolveMiniDoc?{}", base.as_str().trim_end_matches('/').to_string() + "/", qs ) diff --git a/crates/jacquard-repo/src/mst/util.rs b/crates/jacquard-repo/src/mst/util.rs index e09dee81..9e95a2d8 100644 --- a/crates/jacquard-repo/src/mst/util.rs +++ b/crates/jacquard-repo/src/mst/util.rs @@ -11,6 +11,7 @@ use crate::storage::BlockStore; use bytes::Bytes; use cid::Cid as IpldCid; use sha2::{Digest, Sha256}; +use smol_str::{SmolStr, ToSmolStr, format_smolstr}; /// Compute CID from raw bytes /// @@ -129,7 +130,7 @@ pub fn serialize_node_data<'a, S: BlockStore + Sync + 'static>( } // Process remaining entries - let mut last_key = String::new(); + let mut last_key = SmolStr::new(""); while i < entries.len() { let entry = &entries[i]; @@ -160,7 +161,7 @@ pub fn serialize_node_data<'a, S: BlockStore + Sync + 'static>( tree: tree_ptr, }); - last_key = key.as_str().to_string(); + last_key = key.as_str().to_smolstr(); } else { return Err( MstError::InvalidNode("Two Trees adjacent in flat entries".into()).into(), @@ -196,17 +197,17 @@ pub fn deserialize_node_data( } // Process entries - let mut last_key = String::new(); + let mut last_key = SmolStr::new(""); for entry in &data.entries { // Reconstruct full key from prefix let key_str = std::str::from_utf8(&entry.key_suffix) .map_err(|e| MstError::InvalidNode(format!("Invalid UTF-8 in key suffix: {}", e)))?; let prefix_len = entry.prefix_len as usize; - let full_key = format!("{}{}", &last_key[..prefix_len], key_str); + let full_key = format_smolstr!("{}{}", &last_key[..prefix_len], key_str); // Append Leaf entries.push(NodeEntry::Leaf { - key: smol_str::SmolStr::new(&full_key), + key: full_key.clone(), value: entry.value, }); diff --git a/crates/jacquard-repo/src/repo.rs b/crates/jacquard-repo/src/repo.rs index 79658a06..addd8375 100644 --- a/crates/jacquard-repo/src/repo.rs +++ b/crates/jacquard-repo/src/repo.rs @@ -332,25 +332,66 @@ where Ok(old_cid) } - // TODO(cursor-based queries): Potential future API additions - // - // The current API is purely single-record CRUD. Cursor-based traversal (see mst/cursor.rs) - // would enable efficient collection/range queries: - // - // - list_collection(collection: &Nsid) -> Vec<(RecordKey, IpldCid)> - // Enumerate all records in a collection via prefix search on "collection/" - // Uses cursor.advance() + cursor.skip_subtree() to skip irrelevant branches - // - // - list_collection_range(collection: &Nsid, start: &Rkey, end: &Rkey) -> Vec<...> - // Range query: advance to start key, collect until > end, skip subtrees outside range - // Useful for pagination / time-bounded queries (since Rkeys are often TIDs) - // - // - list_all_collections() -> Vec - // Walk tree, track collection prefixes, skip subtrees once prefix changes - // - // Current single-key get() is already optimal (O(log n) targeted lookup). - // But these bulk operations would benefit significantly from cursor's skip_subtree() - // to avoid traversing unrelated branches when searching lexicographically-organized data. + /// List all records in a collection. + /// + /// Returns `(rkey, cid)` pairs for every record under the given collection + /// NSID, sorted lexicographically by rkey. Uses cursor-based traversal with + /// subtree skipping for efficiency on large repositories. + pub async fn list_collection( + &self, + collection: &Nsid, + ) -> Result> { + use crate::mst::cursor::{CursorPosition, MstCursor}; + + let prefix = format!("{}/", collection.as_ref()); + let mut cursor = MstCursor::new(self.mst.clone()); + let mut results = Vec::new(); + + // Step into the root + cursor.advance().await?; + + while !cursor.is_end() { + match cursor.current().clone() { + CursorPosition::Leaf { key, cid } => { + if key.starts_with(&prefix) { + let rkey = smol_str::SmolStr::new(&key[prefix.len()..]); + results.push((rkey, cid)); + } else if key.as_str() > prefix.as_str() { + // Past the collection lexicographically — done + break; + } + cursor.advance().await?; + } + CursorPosition::Tree { .. } => { + cursor.advance().await?; + } + CursorPosition::End => break, + } + } + + Ok(results) + } + + /// List all records in a collection with their data. + /// + /// Like [`list_collection`](Self::list_collection) but also reads each + /// record's block data from storage and returns it as raw bytes. Records + /// whose blocks are missing from storage are silently skipped. + pub async fn list_collection_data( + &self, + collection: &Nsid, + ) -> Result> { + let entries = self.list_collection(collection).await?; + let mut results = Vec::with_capacity(entries.len()); + + for (rkey, cid) in entries { + if let Some(data) = self.storage.get(&cid).await? { + results.push((rkey, cid, data)); + } + } + + Ok(results) + } /// Create a commit from record write operations /// @@ -1267,4 +1308,117 @@ mod tests { .is_some() ); } + + #[tokio::test] + async fn test_list_collection() { + use crate::mst::RecordWriteOp; + + let storage = Arc::new(MemoryBlockStore::new()); + let mut repo = create_test_repo(storage.clone()).await; + + let posts = Nsid::new("app.bsky.feed.post").unwrap().into_static(); + let likes = Nsid::new("app.bsky.feed.like").unwrap().into_static(); + let did = Did::new("did:plc:test").unwrap().into_static(); + let signing_key = k256::ecdsa::SigningKey::random(&mut rand::rngs::OsRng); + + let ops = vec![ + RecordWriteOp::Create { + collection: posts.clone(), + rkey: RecordKey(Rkey::new("aaa").unwrap()).into_static(), + record: make_test_record(1), + }, + RecordWriteOp::Create { + collection: posts.clone(), + rkey: RecordKey(Rkey::new("bbb").unwrap()).into_static(), + record: make_test_record(2), + }, + RecordWriteOp::Create { + collection: posts.clone(), + rkey: RecordKey(Rkey::new("ccc").unwrap()).into_static(), + record: make_test_record(3), + }, + RecordWriteOp::Create { + collection: likes.clone(), + rkey: RecordKey(Rkey::new("zzz").unwrap()).into_static(), + record: make_test_record(4), + }, + ]; + + let (_, commit_data) = repo + .create_commit( + &ops, + &did, + Some(repo.current_commit_cid().clone()), + &signing_key, + ) + .await + .unwrap(); + repo.apply_commit(commit_data).await.unwrap(); + + // List posts — should get 3 entries + let post_entries = repo.list_collection(&posts).await.unwrap(); + assert_eq!(post_entries.len(), 3); + let rkeys: Vec<&str> = post_entries.iter().map(|(k, _)| k.as_str()).collect(); + assert_eq!(rkeys, vec!["aaa", "bbb", "ccc"]); + + // List likes — should get 1 entry + let like_entries = repo.list_collection(&likes).await.unwrap(); + assert_eq!(like_entries.len(), 1); + assert_eq!(like_entries[0].0.as_str(), "zzz"); + + // List nonexistent collection — should get 0 entries + let empty_nsid = Nsid::new("app.bsky.graph.follow").unwrap().into_static(); + let empty = repo.list_collection(&empty_nsid).await.unwrap(); + assert!(empty.is_empty()); + } + + #[tokio::test] + async fn test_list_collection_data() { + use crate::mst::RecordWriteOp; + + let storage = Arc::new(MemoryBlockStore::new()); + let mut repo = create_test_repo(storage.clone()).await; + + let posts = Nsid::new("app.bsky.feed.post").unwrap().into_static(); + let did = Did::new("did:plc:test").unwrap().into_static(); + let signing_key = k256::ecdsa::SigningKey::random(&mut rand::rngs::OsRng); + + let ops = vec![ + RecordWriteOp::Create { + collection: posts.clone(), + rkey: RecordKey(Rkey::new("post1").unwrap()).into_static(), + record: make_test_record(1), + }, + RecordWriteOp::Create { + collection: posts.clone(), + rkey: RecordKey(Rkey::new("post2").unwrap()).into_static(), + record: make_test_record(2), + }, + ]; + + let (_, commit_data) = repo + .create_commit( + &ops, + &did, + Some(repo.current_commit_cid().clone()), + &signing_key, + ) + .await + .unwrap(); + repo.apply_commit(commit_data).await.unwrap(); + + let entries = repo.list_collection_data(&posts).await.unwrap(); + assert_eq!(entries.len(), 2); + + // Verify we can deserialize the record data + for (rkey, _cid, data) in &entries { + let record: BTreeMap = + serde_ipld_dagcbor::from_slice(data).unwrap(); + assert_eq!( + record.get(&SmolStr::new("$type")).unwrap(), + &RawData::String("app.bsky.feed.post".into()) + ); + assert!(rkey.as_str() == "post1" || rkey.as_str() == "post2"); + } + } }