mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-21 16:03:32 +01:00
80 lines
2.4 KiB
Go
80 lines
2.4 KiB
Go
// Code generated by "enumer -type=ReplicationGuaranteeKind -json -transform=snake -trimprefix=ReplicationGuaranteeKind"; DO NOT EDIT.
|
|
|
|
package endpoint
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
_ReplicationGuaranteeKindName_0 = "resumabilityincremental"
|
|
_ReplicationGuaranteeKindName_1 = "none"
|
|
)
|
|
|
|
var (
|
|
_ReplicationGuaranteeKindIndex_0 = [...]uint8{0, 12, 23}
|
|
_ReplicationGuaranteeKindIndex_1 = [...]uint8{0, 4}
|
|
)
|
|
|
|
func (i ReplicationGuaranteeKind) String() string {
|
|
switch {
|
|
case 1 <= i && i <= 2:
|
|
i -= 1
|
|
return _ReplicationGuaranteeKindName_0[_ReplicationGuaranteeKindIndex_0[i]:_ReplicationGuaranteeKindIndex_0[i+1]]
|
|
case i == 4:
|
|
return _ReplicationGuaranteeKindName_1
|
|
default:
|
|
return fmt.Sprintf("ReplicationGuaranteeKind(%d)", i)
|
|
}
|
|
}
|
|
|
|
var _ReplicationGuaranteeKindValues = []ReplicationGuaranteeKind{1, 2, 4}
|
|
|
|
var _ReplicationGuaranteeKindNameToValueMap = map[string]ReplicationGuaranteeKind{
|
|
_ReplicationGuaranteeKindName_0[0:12]: 1,
|
|
_ReplicationGuaranteeKindName_0[12:23]: 2,
|
|
_ReplicationGuaranteeKindName_1[0:4]: 4,
|
|
}
|
|
|
|
// ReplicationGuaranteeKindString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func ReplicationGuaranteeKindString(s string) (ReplicationGuaranteeKind, error) {
|
|
if val, ok := _ReplicationGuaranteeKindNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to ReplicationGuaranteeKind values", s)
|
|
}
|
|
|
|
// ReplicationGuaranteeKindValues returns all values of the enum
|
|
func ReplicationGuaranteeKindValues() []ReplicationGuaranteeKind {
|
|
return _ReplicationGuaranteeKindValues
|
|
}
|
|
|
|
// IsAReplicationGuaranteeKind returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i ReplicationGuaranteeKind) IsAReplicationGuaranteeKind() bool {
|
|
for _, v := range _ReplicationGuaranteeKindValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalJSON implements the json.Marshaler interface for ReplicationGuaranteeKind
|
|
func (i ReplicationGuaranteeKind) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(i.String())
|
|
}
|
|
|
|
// UnmarshalJSON implements the json.Unmarshaler interface for ReplicationGuaranteeKind
|
|
func (i *ReplicationGuaranteeKind) UnmarshalJSON(data []byte) error {
|
|
var s string
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
return fmt.Errorf("ReplicationGuaranteeKind should be a string, got %s", data)
|
|
}
|
|
|
|
var err error
|
|
*i, err = ReplicationGuaranteeKindString(s)
|
|
return err
|
|
}
|