Documentation ¶
Overview ¶
Package option provides the ability to create omittable primitives. This is accomplished by pointerrizing common primitive types so that they may assume a nil value, which is considered as omitted by encoding/json. To generate pointerrized primitives, there are helper functions NewT() for each option type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( True = newBool(true) False = newBool(false) )
var ( // NullBool serializes to JSON null. NullBool = &NullableBoolData{} NullableTrue = &NullableBoolData{ Val: true, Init: true, } NullableFalse = &NullableBoolData{ Val: false, Init: true, } )
var NullColor = &NullableColorData{}
NullColor serializes to JSON null.
var NullInt = &NullableIntData{}
NullInt serializes to JSON null.
var NullString = &NullableStringData{}
NullBool serializes to JSON null.
var NullUint = &NullableUintData{}
NullUint serializes to JSON null.
var ZeroInt = NewInt(0)
ZeroInt is an Int with 0 as value.
var ZeroSeconds = NewSeconds(0)
ZeroSeconds are 0 Seconds.
var ZeroUint = NewUint(0)
ZeroUint is a Uint with 0 as value.
Functions ¶
This section is empty.
Types ¶
type NullableBool ¶
type NullableBool = *NullableBoolData
NullableBool is the nullable type for bool.
type NullableBoolData ¶ added in v0.7.2
func (NullableBoolData) MarshalJSON ¶ added in v0.7.2
func (b NullableBoolData) MarshalJSON() ([]byte, error)
func (*NullableBoolData) UnmarshalJSON ¶ added in v0.7.2
func (b *NullableBoolData) UnmarshalJSON(json []byte) (err error)
type NullableColor ¶
type NullableColor = *NullableColorData
Nullable is a nullable version of discord.Color.
func NewNullableColor ¶
func NewNullableColor(v discord.Color) NullableColor
NewNullableColor creates a new non-null NullableColor using the value of the passed discord.Color.
type NullableColorData ¶ added in v0.7.2
func (NullableColorData) MarshalJSON ¶ added in v0.7.2
func (i NullableColorData) MarshalJSON() ([]byte, error)
func (*NullableColorData) UnmarshalJSON ¶ added in v0.7.2
func (i *NullableColorData) UnmarshalJSON(json []byte) error
type NullableInt ¶
type NullableInt = *NullableIntData
NullableInt is a nullable version of an integer (int).
func NewNullableInt ¶
func NewNullableInt(v int) NullableInt
NewInt creates a new non-null NullableInt using the value of the passed int.
type NullableIntData ¶ added in v0.7.2
func (NullableIntData) MarshalJSON ¶ added in v0.7.2
func (i NullableIntData) MarshalJSON() ([]byte, error)
func (*NullableIntData) UnmarshalJSON ¶ added in v0.7.2
func (i *NullableIntData) UnmarshalJSON(json []byte) error
type NullableString ¶
type NullableString = *NullableStringData
NullableString is a nullable version of a string.
func NewNullableString ¶
func NewNullableString(v string) NullableString
NewNullableString creates a new non-null NullableString with the value of the passed string.
type NullableStringData ¶ added in v0.7.2
func (NullableStringData) MarshalJSON ¶ added in v0.7.2
func (s NullableStringData) MarshalJSON() ([]byte, error)
func (*NullableStringData) UnmarshalJSON ¶ added in v0.7.2
func (s *NullableStringData) UnmarshalJSON(b []byte) error
type NullableUint ¶
type NullableUint = *NullableUintData
NullableUint is a nullable version of an unsigned integer (uint).
func NewNullableUint ¶
func NewNullableUint(v uint) NullableUint
NewUint creates a new non-null NullableUint using the value of the passed uint.
type NullableUintData ¶ added in v0.7.2
func (NullableUintData) MarshalJSON ¶ added in v0.7.2
func (u NullableUintData) MarshalJSON() ([]byte, error)
func (*NullableUintData) UnmarshalJSON ¶ added in v0.7.2
func (u *NullableUintData) UnmarshalJSON(json []byte) error
type Seconds ¶
Seconds is the option type for discord.Seconds.
func NewSeconds ¶
NewString creates a new Seconds with the value of the passed discord.Seconds.