Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DisplayFormatter ¶
type DisplayFormatter interface {
// Encode converts a raw value to a human-readable string.
Encode(value any) (string, error)
// Decode converts a human-readable string back to a raw value.
Decode(display string) (any, error)
}
DisplayFormatter converts between raw values and human-readable strings.
type FormatRegistry ¶
type FormatRegistry struct {
// contains filtered or unexported fields
}
FormatRegistry manages registered display format converters.
func NewDefaultFormatRegistry ¶
func NewDefaultFormatRegistry() *FormatRegistry
NewDefaultFormatRegistry creates a FormatRegistry pre-loaded with the built-in formatters: "ipv4", "mac", and "ipv6".
func NewFormatRegistry ¶
func NewFormatRegistry() *FormatRegistry
NewFormatRegistry creates a new empty FormatRegistry.
func (*FormatRegistry) Get ¶
func (r *FormatRegistry) Get(name string) (DisplayFormatter, error)
Get retrieves a display format converter by name. Returns FormatNotFoundError if the format is not registered.
func (*FormatRegistry) Has ¶
func (r *FormatRegistry) Has(name string) bool
Has checks whether a display format is registered.
func (*FormatRegistry) Register ¶
func (r *FormatRegistry) Register(name string, formatter DisplayFormatter)
Register adds a display format converter to the registry.
type IPv4Formatter ¶
type IPv4Formatter struct{}
IPv4Formatter converts between a 32-bit unsigned integer and a dotted-decimal string such as "192.168.1.1".
type IPv6Formatter ¶
type IPv6Formatter struct{}
IPv6Formatter converts between a 128-bit value and a colon-separated hex group string such as "2001:0db8:0000:0000:0000:0000:0000:0001".
The Encode method accepts [16]byte, []byte (length 16), *big.Int, or big.Int. The Decode method returns a *big.Int.
type MACFormatter ¶
type MACFormatter struct{}
MACFormatter converts between a 48-bit integer and a colon-separated hex string such as "aa:bb:cc:dd:ee:ff".