Documentation ¶
Index ¶
- Variables
- func WithKDBX4Formatting(t *TimeWrapper)
- type BoolWrapper
- type NullableBoolWrapper
- func (b *NullableBoolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (b *NullableBoolWrapper) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (b *NullableBoolWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (b *NullableBoolWrapper) UnmarshalXMLAttr(attr xml.Attr) error
- type TimeOption
- type TimeWrapper
Constants ¶
This section is empty.
Variables ¶
var ErrYearOutsideOfRange = errors.New("Wrappers.Time.MarshalText: year outside of range [0,9999]")
ErrYearOutsideOfRange is the error returned when the year is outside 0 and 9999
Functions ¶
func WithKDBX4Formatting ¶
func WithKDBX4Formatting(t *TimeWrapper)
Types ¶
type BoolWrapper ¶
type BoolWrapper struct {
Bool bool
}
BoolWrapper is a bool wrapper that provides xml marshaling and unmarshaling
func NewBoolWrapper ¶
func NewBoolWrapper(value bool) BoolWrapper
NewBoolWrapper initializes a wrapper type around a bool value which holds the given value
func (*BoolWrapper) MarshalXML ¶
func (b *BoolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals the boolean into e
func (*BoolWrapper) MarshalXMLAttr ¶
MarshalXMLAttr returns the encoded XML attribute
func (*BoolWrapper) UnmarshalXML ¶
func (b *BoolWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML unmarshals the boolean from d
func (*BoolWrapper) UnmarshalXMLAttr ¶
func (b *BoolWrapper) UnmarshalXMLAttr(attr xml.Attr) error
UnmarshalXMLAttr decodes a single XML attribute
type NullableBoolWrapper ¶ added in v3.0.3
NullableBoolWrapper is a bool wrapper that provides xml un-/marshalling and additionally allows "null" as value.
func NewNullableBoolWrapper ¶ added in v3.0.3
func NewNullableBoolWrapper(value bool) NullableBoolWrapper
NewNullableBoolWrapper initializes a new NewNullableBoolWrapper with the given value and valid `true`.
func (*NullableBoolWrapper) MarshalXML ¶ added in v3.0.3
func (b *NullableBoolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals the boolean into e
func (*NullableBoolWrapper) MarshalXMLAttr ¶ added in v3.0.3
MarshalXMLAttr returns the encoded XML attribute
func (*NullableBoolWrapper) UnmarshalXML ¶ added in v3.0.3
func (b *NullableBoolWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML unmarshals the boolean from d
func (*NullableBoolWrapper) UnmarshalXMLAttr ¶ added in v3.0.3
func (b *NullableBoolWrapper) UnmarshalXMLAttr(attr xml.Attr) error
UnmarshalXMLAttr decodes a single XML attribute
type TimeOption ¶
type TimeOption func(*TimeWrapper)
func WithFormatted ¶
func WithFormatted(formatted bool) TimeOption
type TimeWrapper ¶
type TimeWrapper struct { Formatted bool // True for Kdbx v3.1 (formatted as RFC3339) Time time.Time // Time value }
TimeWrapper is a time.Time wrapper that provides xml marshaling and unmarshaling
func Now ¶
func Now(options ...TimeOption) TimeWrapper
Now returns a TimeWrapper instance with the current time in UTC
func (TimeWrapper) MarshalText ¶
func (tw TimeWrapper) MarshalText() ([]byte, error)
MarshalText marshals time into an RFC3339 compliant value in UTC (Kdbx v3.1) On Kdbx v4 it calculates the timestamp subtracting seconds from the time date and encode it with base64
func (TimeWrapper) String ¶
func (tw TimeWrapper) String() string
func (*TimeWrapper) UnmarshalText ¶
func (tw *TimeWrapper) UnmarshalText(data []byte) error
UnmarshalText take a string of format time.RFC3339 and marshals it into the TimeWrapper value (Kdbx v3.1) On Kdbx v4 it calculates the time with given seconds via data byte array (base64 encoded)