Files
threshold/internal/bsr/compression.go
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

67 lines
1.1 KiB
Go

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package bsr
import (
"bytes"
"io"
)
const (
compressionSize = 1
)
// Compression is used to identify the compression used for the data in chunks.
type Compression uint8
// Supported compression methods.
const (
NoCompression Compression = iota
GzipCompression
)
func (c Compression) String() string {
switch c {
case NoCompression:
return "no compression"
case GzipCompression:
return "gzip"
default:
return "unknown compression"
}
}
// ValidCompression checks if a given Compression is valid.
func ValidCompression(c Compression) bool {
switch c {
case NoCompression, GzipCompression:
return true
}
return false
}
type nullCompressionWriter struct {
*bytes.Buffer
}
func (w *nullCompressionWriter) Close() error {
return nil
}
func newNullCompressionWriter(b *bytes.Buffer) io.WriteCloser {
return &nullCompressionWriter{Buffer: b}
}
type nullCompressionReader struct {
*bytes.Buffer
}
func (w *nullCompressionReader) Close() error {
return nil
}
func newNullCompressionReader(b *bytes.Buffer) io.ReadCloser {
return &nullCompressionReader{Buffer: b}
}