mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
117 lines
3.5 KiB
Go
117 lines
3.5 KiB
Go
|
// Code generated by "enumer -type EllipticCurve -trimprefix EllipticCurve -text -json -linecomment"; DO NOT EDIT.
|
||
|
|
||
|
package crypto
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
const _EllipticCurveName = "P256P384P512"
|
||
|
|
||
|
var _EllipticCurveIndex = [...]uint8{0, 0, 4, 8, 12}
|
||
|
|
||
|
const _EllipticCurveLowerName = "p256p384p512"
|
||
|
|
||
|
func (i EllipticCurve) String() string {
|
||
|
if i < 0 || i >= EllipticCurve(len(_EllipticCurveIndex)-1) {
|
||
|
return fmt.Sprintf("EllipticCurve(%d)", i)
|
||
|
}
|
||
|
return _EllipticCurveName[_EllipticCurveIndex[i]:_EllipticCurveIndex[i+1]]
|
||
|
}
|
||
|
|
||
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||
|
// Re-run the stringer command to generate them again.
|
||
|
func _EllipticCurveNoOp() {
|
||
|
var x [1]struct{}
|
||
|
_ = x[EllipticCurveUnspecified-(0)]
|
||
|
_ = x[EllipticCurveP256-(1)]
|
||
|
_ = x[EllipticCurveP384-(2)]
|
||
|
_ = x[EllipticCurveP512-(3)]
|
||
|
}
|
||
|
|
||
|
var _EllipticCurveValues = []EllipticCurve{EllipticCurveUnspecified, EllipticCurveP256, EllipticCurveP384, EllipticCurveP512}
|
||
|
|
||
|
var _EllipticCurveNameToValueMap = map[string]EllipticCurve{
|
||
|
_EllipticCurveName[0:0]: EllipticCurveUnspecified,
|
||
|
_EllipticCurveLowerName[0:0]: EllipticCurveUnspecified,
|
||
|
_EllipticCurveName[0:4]: EllipticCurveP256,
|
||
|
_EllipticCurveLowerName[0:4]: EllipticCurveP256,
|
||
|
_EllipticCurveName[4:8]: EllipticCurveP384,
|
||
|
_EllipticCurveLowerName[4:8]: EllipticCurveP384,
|
||
|
_EllipticCurveName[8:12]: EllipticCurveP512,
|
||
|
_EllipticCurveLowerName[8:12]: EllipticCurveP512,
|
||
|
}
|
||
|
|
||
|
var _EllipticCurveNames = []string{
|
||
|
_EllipticCurveName[0:0],
|
||
|
_EllipticCurveName[0:4],
|
||
|
_EllipticCurveName[4:8],
|
||
|
_EllipticCurveName[8:12],
|
||
|
}
|
||
|
|
||
|
// EllipticCurveString retrieves an enum value from the enum constants string name.
|
||
|
// Throws an error if the param is not part of the enum.
|
||
|
func EllipticCurveString(s string) (EllipticCurve, error) {
|
||
|
if val, ok := _EllipticCurveNameToValueMap[s]; ok {
|
||
|
return val, nil
|
||
|
}
|
||
|
|
||
|
if val, ok := _EllipticCurveNameToValueMap[strings.ToLower(s)]; ok {
|
||
|
return val, nil
|
||
|
}
|
||
|
return 0, fmt.Errorf("%s does not belong to EllipticCurve values", s)
|
||
|
}
|
||
|
|
||
|
// EllipticCurveValues returns all values of the enum
|
||
|
func EllipticCurveValues() []EllipticCurve {
|
||
|
return _EllipticCurveValues
|
||
|
}
|
||
|
|
||
|
// EllipticCurveStrings returns a slice of all String values of the enum
|
||
|
func EllipticCurveStrings() []string {
|
||
|
strs := make([]string, len(_EllipticCurveNames))
|
||
|
copy(strs, _EllipticCurveNames)
|
||
|
return strs
|
||
|
}
|
||
|
|
||
|
// IsAEllipticCurve returns "true" if the value is listed in the enum definition. "false" otherwise
|
||
|
func (i EllipticCurve) IsAEllipticCurve() bool {
|
||
|
for _, v := range _EllipticCurveValues {
|
||
|
if i == v {
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
// MarshalJSON implements the json.Marshaler interface for EllipticCurve
|
||
|
func (i EllipticCurve) MarshalJSON() ([]byte, error) {
|
||
|
return json.Marshal(i.String())
|
||
|
}
|
||
|
|
||
|
// UnmarshalJSON implements the json.Unmarshaler interface for EllipticCurve
|
||
|
func (i *EllipticCurve) UnmarshalJSON(data []byte) error {
|
||
|
var s string
|
||
|
if err := json.Unmarshal(data, &s); err != nil {
|
||
|
return fmt.Errorf("EllipticCurve should be a string, got %s", data)
|
||
|
}
|
||
|
|
||
|
var err error
|
||
|
*i, err = EllipticCurveString(s)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// MarshalText implements the encoding.TextMarshaler interface for EllipticCurve
|
||
|
func (i EllipticCurve) MarshalText() ([]byte, error) {
|
||
|
return []byte(i.String()), nil
|
||
|
}
|
||
|
|
||
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for EllipticCurve
|
||
|
func (i *EllipticCurve) UnmarshalText(text []byte) error {
|
||
|
var err error
|
||
|
*i, err = EllipticCurveString(string(text))
|
||
|
return err
|
||
|
}
|