1package gocql
2
3import (
4	"github.com/golang/snappy"
5)
6
7type Compressor interface {
8	Name() string
9	Encode(data []byte) ([]byte, error)
10	Decode(data []byte) ([]byte, error)
11}
12
13// SnappyCompressor implements the Compressor interface and can be used to
14// compress incoming and outgoing frames. The snappy compression algorithm
15// aims for very high speeds and reasonable compression.
16type SnappyCompressor struct{}
17
18func (s SnappyCompressor) Name() string {
19	return "snappy"
20}
21
22func (s SnappyCompressor) Encode(data []byte) ([]byte, error) {
23	return snappy.Encode(nil, data), nil
24}
25
26func (s SnappyCompressor) Decode(data []byte) ([]byte, error) {
27	return snappy.Decode(nil, data)
28}
29