Documentation ¶
Overview ¶
Package astval provides a set of value types used to serialize configuration data for asterisk phone servers.
Many of the types in this package have an "unspecified" zero value that will not be serialized. This assists with creation of config structures that preserve default values for settings that have not been explicitly set.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( One = OneZeroNone(ternaryTrue) Zero = OneZeroNone(ternaryFalse) )
Boolean states for One/Zero.
var ( On = OnOffNone(ternaryTrue) Off = OnOffNone(ternaryFalse) )
Boolean states for On/Off.
var ( Yes = YesNoNone(ternaryTrue) No = YesNoNone(ternaryFalse) )
Boolean states for Yes/No.
Functions ¶
This section is empty.
Types ¶
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is an integer value.
Its zero value indicates an unspecified condition that will not be marshaled.
func (Int) MarshalAsteriskSetting ¶
MarshalAsteriskSetting writes the value of i to w.
The value of i will not be written when i is equal to the zero value of Int.
type OnOff ¶
type OnOff bool
OnOff is a boolean value that will be marshaled as "on" or "off".
func (OnOff) MarshalText ¶
MarshalText marshals the boolean as "on" or "off".
func (*OnOff) UnmarshalText ¶
UnmarshalText parses "on" or "off" as a boolean value.
type OnOffNone ¶
type OnOffNone ternary
OnOffNone is a ternary value that will be marshaled as "on" or "off".
Its zero value indicates an unspecified condition that will not be marshaled.
func (OnOffNone) MarshalAsteriskSetting ¶
MarshalAsteriskSetting writes the value of b to w as "on" or "off".
The value of b will not be written when b is equal to the zero value of OnOff.
func (OnOffNone) MarshalText ¶
MarshalText marshals the ternary value as "on", "off" or nil.
func (*OnOffNone) UnmarshalText ¶
UnmarshalText parses "on", "off" or "" as a ternary value.
type OneZero ¶
type OneZero bool
OneZero is a boolean value that will be marshaled as "1" or "0".
func (OneZero) MarshalText ¶
MarshalText marshals the boolean as "1" or "0".
func (*OneZero) UnmarshalText ¶
UnmarshalText parses "1" or "0" as a boolean value.
type OneZeroNone ¶
type OneZeroNone ternary
OneZeroNone is a ternary value that will be marshaled as "1" or "0".
Its zero value indicates an unspecified condition that will not be marshaled.
func (OneZeroNone) False ¶
func (t OneZeroNone) False() bool
False returns true if t specifies a false value.
func (OneZeroNone) MarshalAsteriskSetting ¶
func (t OneZeroNone) MarshalAsteriskSetting(w io.Writer) error
MarshalAsteriskSetting writes the value of t to w as "1" or "0".
The value of t will not be written when t is unspecified.
func (OneZeroNone) MarshalText ¶
func (t OneZeroNone) MarshalText() ([]byte, error)
MarshalText marshals the ternary value as "1", "0" or nil.
func (OneZeroNone) Specified ¶
func (t OneZeroNone) Specified() bool
Specified returns true if t specifies a value.
func (OneZeroNone) True ¶
func (t OneZeroNone) True() bool
True returns true if t specifies a true value.
func (*OneZeroNone) UnmarshalText ¶
func (t *OneZeroNone) UnmarshalText(text []byte) error
UnmarshalText parses "1", "0" or "" as a ternary value.
type Seconds ¶
type Seconds struct {
// contains filtered or unexported fields
}
Seconds is a time duration that will be marshaled as an integer number of seconds.
Its zero value indicates an unspecified condition that will not be marshaled.
func NewSeconds ¶
NewSeconds returns a time duration that will be marshaled as an integer number of seconds.
func (Seconds) MarshalAsteriskSetting ¶
MarshalAsteriskSetting writes the value of seconds to w as an integral number of seconds.
The value of seconds will not be written when seconds is equal to the zero value of Seconds.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a string value.
Its zero value indicates an unspecified condition that will not be marshaled.
func (String) MarshalAsteriskSetting ¶
MarshalAsteriskSetting writes the value of s to w.
The value of s will not be written when s is equal to the zero value of String.
type Var ¶
Var is an asterisk variable value.
func (Var) MarshalText ¶
MarshalText marshals the variable as a string of utf-8 bytes.
func (*Var) UnmarshalText ¶
UnmarshalText parses an asterisk variable value from a string of utf-8 bytes.
type YesNo ¶
type YesNo bool
YesNo is a boolean value that will be marshaled as "yes" or "no".
func (YesNo) MarshalText ¶
MarshalText marshals the boolean the boolean as "yes" or "no".
func (*YesNo) UnmarshalText ¶
UnmarshalText parses "yes" or "no" as a boolean value.
type YesNoNone ¶
type YesNoNone ternary
YesNoNone is a ternary value that will be marshaled as "yes" or "no".
Its zero value indicates an unspecified condition that will not be marshaled.
func (YesNoNone) MarshalAsteriskSetting ¶
MarshalAsteriskSetting writes the value of b to w as "on" or "off".
The value of b will not be written when b is equal to the zero value of OnOff.
func (YesNoNone) MarshalText ¶
MarshalText marshals the ternary value as "on", "off" or nil.
func (*YesNoNone) UnmarshalText ¶
UnmarshalText parses "on", "off" or "" as a ternary value.