Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseDuration ¶
func ParseDuration(str string) (*durationpb.Duration, error)
ParseDuration parses a duration string into a durationpb.Duration.
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
This function supports the full range of durationpb.Duration values, including those outside the range of time.Duration.
Types ¶
type CustomUnmarshaler ¶ added in v0.4.0
type CustomUnmarshaler interface {
// Unmarshal the given node into the given message.
//
// Returns an error if the node is invalid for the message.
// Returns (true, nil) if the node was handled by the custom unmarshaler.
// Otherwise, returns (false, nil), to indicate that the node should be
// unmarshaled by the default unmarshaler.
//
// When unmarshaling a google.protobuf.Any message, the `@type` field is
// included in the node.
//
// The 'message' argument maybe [dynamicpb.Message] or a concrete message type
// depending on the [UnmarshalOptions].Resolver used.
Unmarshal(node *yaml.Node, message proto.Message) (bool, error)
}
CustomUnmarshaler is an interface for custom unmarshaling of Protobuf messages.
type MarshalOptions ¶
type MarshalOptions struct {
// The number of spaces to indent. Passed to yaml.Encoder.SetIndent.
// If 0, uses the default indent of yaml.v3.
Indent int
// AllowPartial allows messages that have missing required fields to marshal
// without returning an error.
AllowPartial bool
// UseProtoNames uses proto field name instead of lowerCamelCase name in YAML
// field names.
UseProtoNames bool
// UseEnumNumbers emits enum values as numbers.
UseEnumNumbers bool
// EmitUnpopulated specifies whether to emit unpopulated fields.
EmitUnpopulated bool
// Resolver is used for looking up types when expanding google.protobuf.Any
// messages. If nil, this defaults to using protoregistry.GlobalTypes.
Resolver interface {
protoregistry.ExtensionTypeResolver
protoregistry.MessageTypeResolver
}
}
MarshalOptions is a configurable YAML format marshaller.
It uses similar options to protojson.MarshalOptions.
type UnmarshalOptions ¶
type UnmarshalOptions struct {
// The path for the data being unmarshaled.
//
// If set, this will be used when producing error messages.
Path string
// Validator is a validator to run after unmarshaling a message.
Validator Validator
// CustomUnmarshaler is a custom unmarshaler to use for specific message types.
CustomUnmarshaler CustomUnmarshaler
// Resolver is the Protobuf type resolver to use.
Resolver interface {
protoregistry.MessageTypeResolver
protoregistry.ExtensionTypeResolver
}
// If AllowPartial is set, input for messages that will result in missing
// required fields will not return an error.
AllowPartial bool
// DiscardUnknown specifies whether to discard unknown fields instead of
// returning an error.
DiscardUnknown bool
}
UnmarshalOptions is a configurable YAML format parser for Protobuf messages.
Click to show internal directories.
Click to hide internal directories.