compress.go 735 B

1234567891011121314151617181920212223242526272829303132333435
  1. package sessdata
  2. import (
  3. "github.com/lanrenwo/lzsgo"
  4. )
  5. type CmpEncoding interface {
  6. Compress(src []byte, dst []byte) (int, error)
  7. Uncompress(src []byte, dst []byte) (int, error)
  8. }
  9. type LzsgoCmp struct {
  10. }
  11. func (l LzsgoCmp) Compress(src []byte, dst []byte) (int, error) {
  12. n, err := lzsgo.Compress(src, dst)
  13. return n, err
  14. }
  15. func (l LzsgoCmp) Uncompress(src []byte, dst []byte) (int, error) {
  16. n, err := lzsgo.Uncompress(src, dst)
  17. return n, err
  18. }
  19. // type Lz4Cmp struct {
  20. // c lz4.Compressor
  21. // }
  22. // func (l Lz4Cmp) Compress(src []byte, dst []byte) (int, error) {
  23. // return l.c.CompressBlock(src, dst)
  24. // }
  25. // func (l Lz4Cmp) Uncompress(src []byte, dst []byte) (int, error) {
  26. // return lz4.UncompressBlock(src, dst)
  27. // }