Skip to content

Commit c55f3ce

Browse files
feat(sidekick): Generate more samples for oneof main setters. (#2592)
This now generates samples for the main setters of a oneof where the `ExampleField` (i.e. variant) is byte, bool, like float or enum. This currently will have no effect on Rust generated code because Secret Manager and Workflows do not have oneof to which these changes apply.
1 parent 6008979 commit c55f3ce

File tree

1 file changed

+23
-0
lines changed
  • internal/sidekick/internal/rust/templates/common/setter_preamble

1 file changed

+23
-0
lines changed

internal/sidekick/internal/rust/templates/common/setter_preamble/oneof.mustache

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,34 @@ limitations under the License.
2727
/// use {{Group.Codec.ScopeInExamples}};
2828
/// let x = {{Parent.Codec.Name}}::new().set_{{Group.Codec.SetterName}}(Some({{{Group.Codec.RelativeName}}}::{{Codec.BranchName}}("example".to_string())));
2929
{{/IsString}}
30+
{{#IsBytes}}
31+
/// # use {{Parent.Codec.NameInExamples}};
32+
/// use {{Group.Codec.ScopeInExamples}};
33+
/// let x = {{Parent.Codec.Name}}::new().set_{{Group.Codec.SetterName}}(Some({{{Group.Codec.RelativeName}}}::{{Codec.BranchName}}(bytes::Bytes::from_static(b"example"))));
34+
{{/IsBytes}}
35+
{{#IsBool}}
36+
/// # use {{Parent.Codec.NameInExamples}};
37+
/// use {{Group.Codec.ScopeInExamples}};
38+
/// let x = {{Parent.Codec.Name}}::new().set_{{Group.Codec.SetterName}}(Some({{{Group.Codec.RelativeName}}}::{{Codec.BranchName}}(true)));
39+
{{/IsBool}}
3040
{{#IsLikeInt}}
3141
/// # use {{Parent.Codec.NameInExamples}};
3242
/// use {{Group.Codec.ScopeInExamples}};
3343
/// let x = {{Parent.Codec.Name}}::new().set_{{Group.Codec.SetterName}}(Some({{{Group.Codec.RelativeName}}}::{{Codec.BranchName}}(42)));
3444
{{/IsLikeInt}}
45+
{{#IsLikeFloat}}
46+
/// # use {{Parent.Codec.NameInExamples}};
47+
/// use {{Group.Codec.ScopeInExamples}};
48+
/// let x = {{Parent.Codec.Name}}::new().set_{{Group.Codec.SetterName}}(Some({{{Group.Codec.RelativeName}}}::{{Codec.BranchName}}(42.0)));
49+
{{/IsLikeFloat}}
50+
{{#IsEnum}}
51+
/// # use {{Parent.Codec.NameInExamples}};
52+
/// use {{Group.Codec.ScopeInExamples}};
53+
/// use {{EnumType.Codec.NameInExamples}};
54+
{{#EnumType.Codec.ValuesForExamples}}
55+
/// let x{{Index}} = {{FieldParent.Codec.Name}}::new().set_{{Group.Codec.SetterName}}(Some({{{Group.Codec.RelativeName}}}::{{FieldCodec.BranchName}}({{EnumValue.Codec.EnumType}}::{{EnumValue.Codec.VariantName}})));
56+
{{/EnumType.Codec.ValuesForExamples}}
57+
{{/IsEnum}}
3558
{{#IsObject}}
3659
/// # use {{Parent.Codec.NameInExamples}};
3760
/// use {{Group.Codec.ScopeInExamples}};

0 commit comments

Comments
 (0)