-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
compression.go
43 lines (36 loc) · 1.13 KB
/
compression.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// this file was auto-generated by internal/cmd/gentypes/main.go: DO NOT EDIT
package jwa
import (
"github.com/pkg/errors"
)
// CompressionAlgorithm represents the compression algorithms as described in https://tools.ietf.org/html/rfc7518#section-7.3
type CompressionAlgorithm string
// Supported values for CompressionAlgorithm
const (
Deflate CompressionAlgorithm = "DEF" // DEFLATE (RFC 1951)
NoCompress CompressionAlgorithm = "" // No compression
)
// Accept is used when conversion from values given by
// outside sources (such as JSON payloads) is required
func (v *CompressionAlgorithm) Accept(value interface{}) error {
var tmp CompressionAlgorithm
switch x := value.(type) {
case string:
tmp = CompressionAlgorithm(x)
case CompressionAlgorithm:
tmp = x
default:
return errors.Errorf(`invalid type for jwa.CompressionAlgorithm: %T`, value)
}
switch tmp {
case Deflate, NoCompress:
default:
return errors.Errorf(`invalid jwa.CompressionAlgorithm value`)
}
*v = tmp
return nil
}
// String returns the string representation of a CompressionAlgorithm
func (v CompressionAlgorithm) String() string {
return string(v)
}