Documentation
¶
Index ¶
- Variables
- func NewDTMNotEqualIndexError(dtm com.DTM, index int) error
- func NewIncorrectUnmarshallersError(cause error) error
- func NewNilItemError(index int) error
- func NewNotMarshallerError[T any](t T) error
- func NewUnexpectedDTMError(dtm com.DTM) error
- type CmdDTSAdapter
- type Codec
- type Marshaller
- type ResultDTSAdapter
- type Unmarshaller
Constants ¶
This section is empty.
Variables ¶
var EmptySliceErr = errors.New("empty slice")
EmptySliceErr occurs when the Codec is initialized with an empty slice.
Functions ¶
func NewDTMNotEqualIndexError ¶
NewDTMNotEqualIndexError creates an error is the cause of NewIncorrectUnmarshallersError.
func NewIncorrectUnmarshallersError ¶
NewIncorrectUnmarshallersError creates an error that occurs when the codec is initialized with an incorrect slice.
func NewNilItemError ¶
NewNilItemError creates an error is the cause of NewIncorrectUnmarshallersError.
func NewNotMarshallerError ¶
NewNotMarshallerError creates an error that occurs when Codec.Encode parameter doesn't implement the Marshaller interface.
func NewUnexpectedDTMError ¶
NewUnexpectedDTMError creates an error that occurs when Codec.Decode encounters an unexpected DTM.
Types ¶
type CmdDTSAdapter ¶
type CmdDTSAdapter[T base.Cmd[V], V any] struct { // contains filtered or unexported fields }
CmdDTSAdapter implements the Unmarshaller interface and serves as an adapter for Command DTS.
func NewCmdDTSAdapter ¶
func NewCmdDTSAdapter[T base.Cmd[V], V any](d dts.DTS[T]) CmdDTSAdapter[T, V]
Creates a new CmdDTSAdapter.
func (CmdDTSAdapter[T, V]) DTM ¶
func (u CmdDTSAdapter[T, V]) DTM() com.DTM
type Codec ¶
type Codec[T, V any] struct { // contains filtered or unexported fields }
Codec implements the cmd-stream general Codec interface.
func New ¶
func New[T, V any](us []Unmarshaller[V]) (codec Codec[T, V], err error)
New creates a new Codec.
func NewClientCodec ¶
func NewClientCodec[T any](us []Unmarshaller[base.Result]) ( Codec[base.Cmd[T], base.Result], error)
NewClientCodec initializes a cmd-stream client codec.
It accepts a slice of Unmarshallers, where each Unmarshaller's DTM value must match its position in the slice. Example of a correct slice:
[]Unmarshaller[base.Result]{ u0, // u0.DTM() = 0, index = 0 u1, // u1.DTM() = 1, index = 1 u2, // u2.DTM() = 2, index = 2 ... }
Incorrect slices:
[]Unmarshaller{} // Empty slice. []Unmarshaller{ // Contains an item where DTM != index. u0, // u0.DTM() = 1, index = 0 } []Unmarshaller{ // Contains a nil item. nil, }
Returns an error if the provided slice is invalid.
func NewServerCodec ¶
func NewServerCodec[T any](us []Unmarshaller[base.Cmd[T]]) ( Codec[base.Result, base.Cmd[T]], error)
NewServerCodec initializes a cmd-stream server codec.
It accepts a slice of Unmarshallers, where each Unmarshaller's DTM value must match its position in the slice. Example of a correct slice:
[]Unmarshaller[base.Result]{ u0, // u0.DTM() = 0, index = 0 u1, // u1.DTM() = 1, index = 1 u2, // u2.DTM() = 2, index = 2 ... }
Incorrect slices:
[]Unmarshaller{} // Empty slice. []Unmarshaller{ // Contains an item where DTM != index. u0, // u0.DTM() = 1, index = 0 } []Unmarshaller{ // Contains a nil item. nil, }
Returns an error if the provided slice is invalid.
type Marshaller ¶
type Marshaller interface {
Marshal(w transport.Writer) error
}
Marshaller defines a Marshal method that should serialize DTM and data.
type ResultDTSAdapter ¶
type ResultDTSAdapter[T base.Result] struct {
// contains filtered or unexported fields
}
ResultDTSAdapter implements the Unmarshaller interface and serves as an adapter for Result DTS.
func NewResultDTSAdapter ¶
func NewResultDTSAdapter[T base.Result](d dts.DTS[T]) ResultDTSAdapter[T]
NewResultDTSAdapter creates a new ResultDTSAdapter.
func (ResultDTSAdapter[T]) DTM ¶
func (u ResultDTSAdapter[T]) DTM() com.DTM