types

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 14 Imported by: 0

README

Well Known Types

Protobuf have a set of so-called Well Known Types which provide complex types useful in many situations. These types require custom encode and decode functions. This set of types partially implemented in this package.

Empty Doc

Empty represent an empty object.

When encode we produce document start and end with nothing in between.

When decode we read document and throw an error if the document contain something.

Duration Doc

Represent a span of time.

When decode and encode we use the protojson. String field will be produced.

Timestamp Doc

Represent a time point.

When decode and encode we fallback to the default time.Time encode/decode function already presented in the bson.

Time in protojson and protobson packages differs from each other. The protobson uses a DateTime type from the mongo-driver which loose precision but better integrated into the MongoDB data model.

This behavior might be changed in future if it introduce incompatibility or precission loss.

Struct, Value, ListValue Doc

Represent a JSON object.

When decode and encode we work with int/float/double precision pretty loosely. This might be changed in future if this behavior will cause troubles.

Wrappers

Float Doc, Double Doc, Int32 Doc, Int64 Doc, UInt32 Doc, UInt64 Doc, Bool Doc, Bytes Doc, String Doc

Represent some regular types.

When decode and encode we work with int/float/double precision pretty loosely. This might be changed in future if this behavior will cause troubles.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyIsNotEmpty = errors.New("empty object expected to be empty but it is not")
)
View Source
var (
	ErrUnknownValueKind = errors.New("unknown value kind")
)

Functions

This section is empty.

Types

type ProtoDurationCodec

type ProtoDurationCodec struct {
}

ProtoDurationCodec is the Codec used for google.protobuf.Duration type.

func NewProtoDurationCodec

func NewProtoDurationCodec() *ProtoDurationCodec

NewProtoDurationCodec returns a ProtoDurationCodec.

func (*ProtoDurationCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.Duration` message.

func (*ProtoDurationCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.Duration` message.

type ProtoEmptyCodec

type ProtoEmptyCodec struct {
}

ProtoEmptyCodec is the Codec used for google.protobuf.Empty type.

func NewProtoEmptyCodec

func NewProtoEmptyCodec() *ProtoEmptyCodec

NewProtoEmptyCodec returns a ProtoEmptyCodec that uses p for struct tag parsing.

func (*ProtoEmptyCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.Empty` message.

func (*ProtoEmptyCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.Empty` message.

type ProtoStructCodec

type ProtoStructCodec struct {
}

ProtoStructCodec is the Codec used for google.protobuf.Struct type.

func NewProtoStructCodec

func NewProtoStructCodec() *ProtoStructCodec

NewProtoStructCodec returns a ProtoStructCodec that uses p for struct tag parsing.

func (*ProtoStructCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.Struct` message.

func (*ProtoStructCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.Struct` message.

type ProtoStructListValueCodec

type ProtoStructListValueCodec struct {
}

ProtoStructListValueCodec is the Codec used for google.protobuf.ListValue type.

func NewProtoStructListValueCodec

func NewProtoStructListValueCodec() *ProtoStructListValueCodec

NewProtoStructListValueCodec returns a ProtoStructListValueCodec that uses p for struct tag parsing.

func (*ProtoStructListValueCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.Struct` message.

func (*ProtoStructListValueCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.ListValue` message.

type ProtoStructValueCodec

type ProtoStructValueCodec struct {
}

ProtoStructValueCodec is the Codec used for google.protobuf.Value type.

func NewProtoStructValueCodec

func NewProtoStructValueCodec() *ProtoStructValueCodec

NewProtoStructValueCodec returns a ProtoStructValueCodec that uses p for struct tag parsing.

func (*ProtoStructValueCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.Value` message.

func (*ProtoStructValueCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.Value` message.

type ProtoTimestampCodec

type ProtoTimestampCodec struct {
}

ProtoTimestampCodec is the Codec used for google.protobuf.Timestamp type.

func NewProtoTimestampCodec

func NewProtoTimestampCodec() *ProtoTimestampCodec

NewProtoTimestampCodec returns a ProtoEmptyCodec that uses p for struct tag parsing.

func (*ProtoTimestampCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.Timestamp` message.

func (*ProtoTimestampCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.Empty` message.

type ProtoWrappersCodec

type ProtoWrappersCodec struct {
}

ProtoWrappersCodec is the Codec used for google.protobuf.Wrappers type.

func NewProtoWrappersCodec

func NewProtoWrappersCodec() *ProtoWrappersCodec

NewProtoWrappersCodec returns a ProtoWrappersCodec that uses p for struct tag parsing.

func (*ProtoWrappersCodec) DecodeValue

DecodeValue handles decoding of the `google.protobuf.*Value` message.

func (*ProtoWrappersCodec) EncodeValue

EncodeValue handles encoding of the `google.protobuf.*Value` message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL