mirror of https://github.com/0xERR0R/blocky.git
80 lines
2.0 KiB
Go
80 lines
2.0 KiB
Go
// Code generated by go-enum DO NOT EDIT.
|
|
// Version:
|
|
// Revision:
|
|
// Build Date:
|
|
// Built By:
|
|
|
|
package lists
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// ListCacheTypeBlacklist is a ListCacheType of type Blacklist.
|
|
// is a list with blocked domains
|
|
ListCacheTypeBlacklist ListCacheType = iota
|
|
// ListCacheTypeWhitelist is a ListCacheType of type Whitelist.
|
|
// is a list with whitelisted domains / IPs
|
|
ListCacheTypeWhitelist
|
|
)
|
|
|
|
var ErrInvalidListCacheType = fmt.Errorf("not a valid ListCacheType, try [%s]", strings.Join(_ListCacheTypeNames, ", "))
|
|
|
|
const _ListCacheTypeName = "blacklistwhitelist"
|
|
|
|
var _ListCacheTypeNames = []string{
|
|
_ListCacheTypeName[0:9],
|
|
_ListCacheTypeName[9:18],
|
|
}
|
|
|
|
// 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{
|
|
ListCacheTypeBlacklist: _ListCacheTypeName[0:9],
|
|
ListCacheTypeWhitelist: _ListCacheTypeName[9:18],
|
|
}
|
|
|
|
// String implements the Stringer interface.
|
|
func (x ListCacheType) String() string {
|
|
if str, ok := _ListCacheTypeMap[x]; ok {
|
|
return str
|
|
}
|
|
return fmt.Sprintf("ListCacheType(%d)", x)
|
|
}
|
|
|
|
var _ListCacheTypeValue = map[string]ListCacheType{
|
|
_ListCacheTypeName[0:9]: ListCacheTypeBlacklist,
|
|
_ListCacheTypeName[9:18]: ListCacheTypeWhitelist,
|
|
}
|
|
|
|
// 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
|
|
}
|