This repository has been archived by the owner on Aug 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enums.go
72 lines (63 loc) · 2.13 KB
/
enums.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package hasher
// ----------------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------------
// THashAlgo is an enum type that represents the hash algorithm.
// It also implements the fmt.Stringer interface.
type THashAlgo int
// TChkSumAlgo is an enum type that represents the checksum algorithm.
// It also implements the fmt.Stringer interface.
type TChkSumAlgo int
// ----------------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------------
const (
// HashAlgoUnknown is the enum of unknown hash algorithm.
HashAlgoUnknown THashAlgo = iota
// HashAlgoBLAKE3 is the enum of BLAKE3 hash algorithm. This is the default
// set to "hasher.HashAlgo".
HashAlgoBLAKE3
// HashAlgoSHA3_512 is the enum of SHA3-512 hash algorithm. Set this to
// "hasher.HashAlgo" to use this algorithm.
HashAlgoSHA3_512
)
const (
// ChkSumUnknown is the enum of unknown checksum algorithm.
ChkSumUnknown TChkSumAlgo = iota
// ChkSumCRC32 is the enum of CRC32 checksum algorithm. This needs "CRC32Poly"
// variagle, a polynomial to use, to be set as well.
ChkSumCRC32
// ChkSumXXHash is the enum of xxHash algorithm as a checksum.
ChkSumXXHash
)
// ----------------------------------------------------------------------------
// Methods (Implementation of fmt.Stringer)
// ----------------------------------------------------------------------------
// String returns the string representation of the hash algorithm.
// This is an implementation of fmt.Stringer interface.
func (h THashAlgo) String() string {
switch h {
case HashAlgoBLAKE3:
return "blake3"
case HashAlgoSHA3_512:
return "sha3-512"
case HashAlgoUnknown:
fallthrough
default:
return "unknown"
}
}
// String returns the string representation of the hash algorithm.
// This is an implementation of fmt.Stringer interface.
func (h TChkSumAlgo) String() string {
switch h {
case ChkSumCRC32:
return "crc32"
case ChkSumXXHash:
return "xxhash"
case ChkSumUnknown:
fallthrough
default:
return "unknown"
}
}