mdbson

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mdbson supports serialization and deserialization using BSON. Objects with interface fields are serialized and deserialized using madkins23/go-type/reg. This package is patterned after JSON and YAML code in madkins23/go-serial.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pointer added in v0.13.0

type Pointer[T pointer.Target] struct {
	// contains filtered or unexported fields
}

Pointer is used to specify an object that may be found in a cache or DB.

func Point added in v0.13.0

func Point[T pointer.Target](target T) *Pointer[T]

func (*Pointer[T]) Get added in v0.13.0

func (p *Pointer[T]) Get() T

Get the Target item from the Pointer.

func (*Pointer[T]) MarshalBSON added in v0.13.0

func (p *Pointer[T]) MarshalBSON() ([]byte, error)

func (*Pointer[T]) Set added in v0.13.0

func (p *Pointer[T]) Set(t T)

Set the Target item for the Pointer.

func (*Pointer[T]) UnmarshalBSON added in v0.13.0

func (p *Pointer[T]) UnmarshalBSON(marshaled []byte) error

type Wrapper

type Wrapper[T any] struct {
	// contains filtered or unexported fields
}

Wrapper is used to attach a type name to an item to be serialized. This supports re-creating the correct type for filling an interface field.

func Wrap

func Wrap[W any](item W) *Wrapper[W]

Wrap an item in a BSON wrapper that can handle serialization.

func (*Wrapper[T]) Get

func (w *Wrapper[T]) Get() T

Get the wrapped item.

func (*Wrapper[T]) MarshalBSON

func (w *Wrapper[T]) MarshalBSON() ([]byte, error)

func (*Wrapper[T]) Set

func (w *Wrapper[T]) Set(t T)

Set the wrapped item.

func (*Wrapper[T]) UnmarshalBSON

func (w *Wrapper[T]) UnmarshalBSON(marshaled []byte) error

Jump to

Keyboard shortcuts

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