github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/packer.go (about) 1 package kiwi 2 3 import "github.com/15mga/kiwi/util" 4 5 var ( 6 _Packer IPacker 7 ) 8 9 func Packer() IPacker { 10 return _Packer 11 } 12 13 func SetPacker(packer IPacker) { 14 _Packer = packer 15 } 16 17 type IPacker interface { 18 PackWatchNotify(id int64, methods []TCode) []byte 19 UnpackWatchNotify(bytes []byte) (id int64, methods []TCode, err *util.Err) 20 PackPush(tid int64, pus ISndPush) ([]byte, *util.Err) 21 UnpackPush(bytes []byte, pkg IRcvPush) (err *util.Err) 22 UnpackPushBytes(bytes []byte, head util.M) (tid int64, json bool, payload []byte, err *util.Err) 23 PackRequest(tid int64, req ISndRequest) ([]byte, *util.Err) 24 UnpackRequest(bytes []byte, pkg IRcvRequest) (err *util.Err) 25 PackResponseOk(tid int64, head util.M, pkt []byte) ([]byte, *util.Err) 26 UnpackResponseOk(bytes []byte, head util.M) (tid int64, payload []byte, err *util.Err) 27 PackResponseFail(tid int64, head util.M, code uint16) ([]byte, *util.Err) 28 UnpackResponseFail(bytes []byte, head util.M) (tid int64, code uint16, readErr *util.Err) 29 PackNotify(tid int64, ntf ISndNotice) ([]byte, *util.Err) 30 UnpackNotify(bytes []byte, pkg IRcvNotice) (err *util.Err) 31 PackM(m util.M) ([]byte, *util.Err) 32 UnpackM(bytes []byte, m util.M) (err *util.Err) 33 }