Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MaxDurationSeconds the maximum number of seconds (when expressed as nanoseconds) which can fit in an int64. // gogoproto encodes google.protobuf.Duration as a time.Duration, which is 64-bit signed integer. MaxDurationSeconds = int64(math.MaxInt64/int(1e9)) - 1 )
Variables ¶
This section is empty.
Functions ¶
func MessageGenerator ¶
func MessageGenerator[T proto.Message](x T, options GeneratorOptions) *rapid.Generator[T]
Types ¶
type FieldMapper ¶
type FieldMapper func(*rapid.T, protoreflect.FieldDescriptor, string) (protoreflect.Value, bool)
FieldMapper is a function that can be used to override the default behavior of the generator for a specific field. The first argument is the rapid.T, the second is the field descriptor, and the third is the field name. If the function returns nil, the default behavior will be used.
type GeneratorOptions ¶
type GeneratorOptions struct { AnyTypeURLs []string InterfaceHints map[string]string Resolver protoregistry.MessageTypeResolver // NoEmptyLists will cause the generator to not generate empty lists // Recall that an empty list will marshal (and unmarshal) to null. Some encodings may treat these states // differently. For example, in JSON, an empty list is encoded as [], while null is encoded as null. NoEmptyLists bool // DisallowNilMessages will cause the generator to not generate nil messages to protoreflect.MessageKind fields DisallowNilMessages bool // FieldMaps is a list of FieldMapper functions that can be used to override the default behavior of the generator // for a specific field. FieldMaps []FieldMapper }
func (GeneratorOptions) WithAnyTypes ¶
func (opts GeneratorOptions) WithAnyTypes(anyTypes ...proto.Message) GeneratorOptions
func (GeneratorOptions) WithDisallowNil ¶
func (opts GeneratorOptions) WithDisallowNil() GeneratorOptions
func (GeneratorOptions) WithInterfaceHint ¶
func (opts GeneratorOptions) WithInterfaceHint(i string, impl proto.Message) GeneratorOptions
Click to show internal directories.
Click to hide internal directories.