srpc/encoder.go

55 lines
794 B
Go
Raw Permalink Normal View History

2020-02-10 02:53:05 +01:00
package srpc
import (
"io"
2021-08-02 23:41:54 +02:00
"gitea.olznet.de/OlzNet/ssob"
2020-02-10 02:53:05 +01:00
)
type IEncoder interface {
Encode(e interface{}) error
}
type IDecoder interface {
Decode(e interface{}) error
}
type IEncoderHandler interface {
NewEncoder(w io.Writer) IEncoder
}
type IDecoderHandler interface {
NewDecoder(r io.Reader) IDecoder
}
type IEncoderDecoder interface {
IEncoderHandler
IDecoderHandler
}
type Encoder struct {
}
func (e *Encoder) NewEncoder(w io.Writer) IEncoder {
return ssob.NewEncoder(w)
}
type Decoder struct {
}
func (d *Decoder) NewDecoder(r io.Reader) IDecoder {
return ssob.NewDecoder(r)
}
type EncoderDecoder struct {
IEncoderHandler
IDecoderHandler
}
func NewEncoderDecoder() IEncoderDecoder {
enc := new(Encoder)
dec := new(Decoder)
return &EncoderDecoder{enc, dec}
}