mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 12:24:30 +08:00
新增压缩功能-LZS算法
This commit is contained in:
35
server/sessdata/compress.go
Normal file
35
server/sessdata/compress.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package sessdata
|
||||
|
||||
import (
|
||||
"github.com/lanrenwo/lzsgo"
|
||||
)
|
||||
|
||||
type CmpEncoding interface {
|
||||
Compress(src []byte, dst []byte) (int, error)
|
||||
Uncompress(src []byte, dst []byte) (int, error)
|
||||
}
|
||||
|
||||
type LzsgoCmp struct {
|
||||
}
|
||||
|
||||
func (l LzsgoCmp) Compress(src []byte, dst []byte) (int, error) {
|
||||
n, err := lzsgo.Compress(src, dst)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (l LzsgoCmp) Uncompress(src []byte, dst []byte) (int, error) {
|
||||
n, err := lzsgo.Uncompress(src, dst)
|
||||
return n, err
|
||||
}
|
||||
|
||||
// type Lz4Cmp struct {
|
||||
// c lz4.Compressor
|
||||
// }
|
||||
|
||||
// func (l Lz4Cmp) Compress(src []byte, dst []byte) (int, error) {
|
||||
// return l.c.CompressBlock(src, dst)
|
||||
// }
|
||||
|
||||
// func (l Lz4Cmp) Uncompress(src []byte, dst []byte) (int, error) {
|
||||
// return lz4.UncompressBlock(src, dst)
|
||||
// }
|
Reference in New Issue
Block a user