mirror of https://github.com/0xERR0R/blocky.git
87 lines
2.2 KiB
Go
87 lines
2.2 KiB
Go
// Code generated by go-enum DO NOT EDIT.
|
|
// Version:
|
|
// Revision:
|
|
// Build Date:
|
|
// Built By:
|
|
|
|
package lists
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// ListCacheTypeDenylist is a ListCacheType of type Denylist.
|
|
// is a list with blocked domains
|
|
ListCacheTypeDenylist ListCacheType = iota
|
|
// ListCacheTypeAllowlist is a ListCacheType of type Allowlist.
|
|
// is a list with allowlisted domains / IPs
|
|
ListCacheTypeAllowlist
|
|
)
|
|
|
|
var ErrInvalidListCacheType = fmt.Errorf("not a valid ListCacheType, try [%s]", strings.Join(_ListCacheTypeNames, ", "))
|
|
|
|
const _ListCacheTypeName = "denylistallowlist"
|
|
|
|
var _ListCacheTypeNames = []string{
|
|
_ListCacheTypeName[0:8],
|
|
_ListCacheTypeName[8:17],
|
|
}
|
|
|
|
// ListCacheTypeNames returns a list of possible string values of ListCacheType.
|
|
func ListCacheTypeNames() []string {
|
|
tmp := make([]string, len(_ListCacheTypeNames))
|
|
copy(tmp, _ListCacheTypeNames)
|
|
return tmp
|
|
}
|
|
|
|
var _ListCacheTypeMap = map[ListCacheType]string{
|
|
ListCacheTypeDenylist: _ListCacheTypeName[0:8],
|
|
ListCacheTypeAllowlist: _ListCacheTypeName[8:17],
|
|
}
|
|
|
|
// String implements the Stringer interface.
|
|
func (x ListCacheType) String() string {
|
|
if str, ok := _ListCacheTypeMap[x]; ok {
|
|
return str
|
|
}
|
|
return fmt.Sprintf("ListCacheType(%d)", x)
|
|
}
|
|
|
|
// IsValid provides a quick way to determine if the typed value is
|
|
// part of the allowed enumerated values
|
|
func (x ListCacheType) IsValid() bool {
|
|
_, ok := _ListCacheTypeMap[x]
|
|
return ok
|
|
}
|
|
|
|
var _ListCacheTypeValue = map[string]ListCacheType{
|
|
_ListCacheTypeName[0:8]: ListCacheTypeDenylist,
|
|
_ListCacheTypeName[8:17]: ListCacheTypeAllowlist,
|
|
}
|
|
|
|
// ParseListCacheType attempts to convert a string to a ListCacheType.
|
|
func ParseListCacheType(name string) (ListCacheType, error) {
|
|
if x, ok := _ListCacheTypeValue[name]; ok {
|
|
return x, nil
|
|
}
|
|
return ListCacheType(0), fmt.Errorf("%s is %w", name, ErrInvalidListCacheType)
|
|
}
|
|
|
|
// MarshalText implements the text marshaller method.
|
|
func (x ListCacheType) MarshalText() ([]byte, error) {
|
|
return []byte(x.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the text unmarshaller method.
|
|
func (x *ListCacheType) UnmarshalText(text []byte) error {
|
|
name := string(text)
|
|
tmp, err := ParseListCacheType(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
*x = tmp
|
|
return nil
|
|
}
|