Documentation
¶
Overview ¶
Format description:
Index ¶
- Constants
- func EnsureEnum[T ~string](knownValues map[T]struct{}, value string) error
- func EnsureLen(words []Word, lenAtLeast int) error
- func Marshal[T any, TP Ptr[T]](src TP, dst *Section) error
- func ReadEnum[T ~string](dst *T, knownValues map[T]struct{}, value string) error
- func ReadEnumAt[T ~string](dst *T, knownValues map[T]struct{}, p []Word, idx int) error
- func RegisterParameterTypeCodec[T any](codec ParameterTypeCodec)
- func SectionKeyword[T any, TP SectionPtr[T]]() string
- func Unmarshal[T any, PT Ptr[T]](src *Section, dst PT) error
- type Include
- type Location
- type Parameter
- type ParameterCodec
- type ParameterMarshaler
- type ParameterTypeCodec
- type ParameterUnmarshaler
- type Ptr
- type Root
- type RootElement
- type Section
- type SectionElement
- type SectionKeyworder
- type SectionPtr
- type Word
Constants ¶
View Source
const TokenMaxLen = 255
Variables ¶
This section is empty.
Functions ¶
func EnsureEnum ¶
func Marshal ¶
Mapping of Parameter Types ¶
All primitive types' zero values should semantically correspond to a missing DRBD section parameter (even for required parameters).
Tags ¶
- `drbd:"parametername"` to select the name of the parameter. There can be one parameterless tag: `drbd:""`, which selects key of the section byitself
- SectionKeyworder and slices of such types SHOULD NOT be tagged, their name is always taken from SectionKeyworder
- subsections should always be represented with struct pointers
- `drbd:"parname1,parname2"` tag value form allows specifying alternative parameter names, which will be tried during unmarshaling. Marshaling will always use the first name.
Primitive Types Support ¶
To add marshaling/unmarshaling support for another primitive type, consider the following options:
- implement ParameterTypeCodec and register it with RegisterParameterTypeCodec. It will be used for every usage of that type, with highest priority. It will even take precendence over built-in slice support. This method is useful for fields of "marker" interface types.
- implement ParameterCodec. This marshaling method is last-effort method, it is used when there's no ParameterTypeCodec for a type
func ReadEnumAt ¶
func RegisterParameterTypeCodec ¶
func RegisterParameterTypeCodec[T any](codec ParameterTypeCodec)
func SectionKeyword ¶
func SectionKeyword[T any, TP SectionPtr[T]]() string
Types ¶
type Location ¶
type ParameterCodec ¶
type ParameterCodec interface {
ParameterMarshaler
ParameterUnmarshaler
}
type ParameterMarshaler ¶
type ParameterTypeCodec ¶
type ParameterUnmarshaler ¶
type Root ¶
type Root struct {
Filename string
Elements []RootElement
}
type RootElement ¶
type RootElement interface {
// contains filtered or unexported methods
}
type Section ¶
type Section struct {
Key []Word
Elements []SectionElement
}
func (*Section) ParametersByKey ¶
type SectionElement ¶
type SectionElement interface {
// contains filtered or unexported methods
}
type SectionKeyworder ¶
type SectionKeyworder interface {
SectionKeyword() string
}
type SectionPtr ¶
type SectionPtr[T any] interface { *T SectionKeyworder }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.