Documentation ¶
Index ¶
- Variables
- func NewImmutable[OuterModelType any, OuterModelPtrType PtrType[OuterModelType, InnerModelType], ...](model *InnerModelType, cacheBytes ...bool) (newInstance *OuterModelType)
- func NewMutable[OuterModelType any, OuterModelPtrType PtrType[OuterModelType, InnerModelType], ...](model *InnerModelType, cacheBytes ...bool) (newInstance *OuterModelType)
- type Immutable
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Bytes() (bytes []byte, err error)
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Decode(b []byte) (int, error)
- func (i Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Encode() ([]byte, error)
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) FromBytes(bytes []byte) (consumedBytes int, err error)
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Init()
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) InnerModel() *InnerModelType
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) New(innerModelType *InnerModelType, cacheBytes ...bool)
- func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) String() string
- type Mutable
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Bytes() (bytes []byte, err error)
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Decode(b []byte) (int, error)
- func (m Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Encode() ([]byte, error)
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) FromBytes(bytes []byte) (consumedBytes int, err error)
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Init()
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) InnerModel() *InnerModelType
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) InvalidateBytesCache()
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) New(innerModelType *InnerModelType, cacheBytes ...bool)
- func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) String() string
- type PtrType
- type ReferencePtrType
- type ReferenceWithMetadataPtrType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrParseBytesFailed is returned if information can not be parsed from a sequence of bytes. ErrParseBytesFailed = errors.New("failed to parse bytes") )
Functions ¶
Types ¶
type Immutable ¶
type Immutable[OuterModelType any, OuterModelPtrType PtrType[OuterModelType, InnerModelType], InnerModelType any] struct { M InnerModelType // contains filtered or unexported fields }
Immutable is the base type for all immutable models. It should be embedded in a wrapper type. It provides serialization primitives.
func (*Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Bytes ¶
func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Bytes() (bytes []byte, err error)
Bytes serializes a model to a byte slice.
func (*Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Decode ¶
func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Decode(b []byte) (int, error)
Decode deserializes the model from a byte slice.
func (Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Encode ¶
Encode serializes the "content of the model" to a byte slice.
func (*Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) FromBytes ¶
func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) FromBytes(bytes []byte) (consumedBytes int, err error)
FromBytes deserializes a model from a byte slice.
func (*Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Init ¶
func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) Init()
Init initializes the model after it has been restored from it's serialized version.
func (*Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) InnerModel ¶
func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) InnerModel() *InnerModelType
InnerModel returns the inner Model that holds the data.
func (*Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) New ¶
func (i *Immutable[OuterModelType, OuterModelPtrType, InnerModelType]) New(innerModelType *InnerModelType, cacheBytes ...bool)
New initializes the model with the necessary values when being manually created through a constructor.
type Mutable ¶
type Mutable[OuterModelType any, OuterModelPtrType PtrType[OuterModelType, InnerModelType], InnerModelType any] struct { M InnerModelType *sync.RWMutex // contains filtered or unexported fields }
Mutable is the base type for simple mutable models. It should be embedded in a wrapper type. It provides serialization and locking primitives.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Bytes ¶
func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Bytes() (bytes []byte, err error)
Bytes serializes a model to a byte slice.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Decode ¶
Decode deserializes the model from a byte slice.
func (Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Encode ¶
Encode serializes the "content of the model" to a byte slice.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) FromBytes ¶
func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) FromBytes(bytes []byte) (consumedBytes int, err error)
FromBytes deserializes a model from a byte slice.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Init ¶
func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) Init()
Init initializes the model after it has been restored from it's serialized version.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) InnerModel ¶
func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) InnerModel() *InnerModelType
InnerModel returns the inner Model that holds the data.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) InvalidateBytesCache ¶
func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) InvalidateBytesCache()
InvalidateBytesCache invalidates the bytes cache.
func (*Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) New ¶
func (m *Mutable[OuterModelType, OuterModelPtrType, InnerModelType]) New(innerModelType *InnerModelType, cacheBytes ...bool)
New initializes the model with the necessary values when being manually created through a constructor.
type PtrType ¶
type PtrType[OuterModelType any, InnerModelType any] interface { *OuterModelType New(innerModelType *InnerModelType, cacheBytes ...bool) Init() InnerModel() *InnerModelType }
PtrType is a type constraint that ensures that all the required methods are available.
type ReferencePtrType ¶
type ReferencePtrType[OuterModelType, SourceIDType, TargetIDType any] interface { *OuterModelType New(SourceIDType, TargetIDType) Init() SourceID() SourceIDType TargetID() TargetIDType }
ReferencePtrType is a type constraint that ensures that all the required methods are available.
type ReferenceWithMetadataPtrType ¶
type ReferenceWithMetadataPtrType[OuterModelType, SourceIDType, TargetIDType, InnerModelType any] interface { *OuterModelType New(SourceIDType, TargetIDType, *InnerModelType) Init() SourceID() SourceIDType TargetID() TargetIDType InnerModel() *InnerModelType }
ReferenceWithMetadataPtrType is a type constraint that ensures that all the required methods are available.