Documentation
¶
Overview ¶
Package proto defines the abstraction for FIT Protocol.
FIT Protocol is the core of a FIT file and it's the fundamental building block for decoding and encoding FIT files.
Index ¶
- Constants
- func CreateMessageDefinitionTo(target *MessageDefinition, mesg *Message)
- func LocalMesgNum(header byte) byte
- func Sizeof(val Value, baseType basetype.BaseType) int
- func Validate(version byte) error
- func VersionMajor(version byte) byte
- func VersionMinor(version byte) byte
- type Component
- type DeveloperField
- type DeveloperFieldDefinition
- type FIT
- type Field
- type FieldBase
- type FieldDefinition
- type FileHeader
- type Message
- func (m Message) Clone() Message
- func (m *Message) FieldByNum(num byte) *Field
- func (m *Message) FieldValueByNum(num byte) Value
- func (m Message) MarshalAppend(b []byte) ([]byte, error)
- func (m Message) MarshalBinary() ([]byte, error)
- func (m *Message) RemoveFieldByNum(num byte)
- func (m Message) WithDeveloperFields(developerFields ...DeveloperField) Message
- func (m Message) WithFieldValues(fieldNumValues map[byte]any) Message
- func (m Message) WithFields(fields ...Field) Message
- type MessageDefinition
- type SubField
- type SubFieldMap
- type Type
- type Validator
- type Value
- func Any(v any) Value
- func Bool(v bool) Value
- func Float32(v float32) Value
- func Float64(v float64) Value
- func Int16(v int16) Value
- func Int32(v int32) Value
- func Int64(v int64) Value
- func Int8(v int8) Value
- func SliceBool[S []E, E ~bool](s S) Value
- func SliceFloat32[S []E, E ~float32](s S) Value
- func SliceFloat64[S []E, E ~float64](s S) Value
- func SliceInt16[S []E, E ~int16](s S) Value
- func SliceInt32[S []E, E ~int32](s S) Value
- func SliceInt64[S []E, E ~int64](s S) Value
- func SliceInt8[S []E, E ~int8](s S) Value
- func SliceString[S []E, E ~string](s S) Value
- func SliceUint16[S []E, E ~uint16](s S) Value
- func SliceUint32[S []E, E ~uint32](s S) Value
- func SliceUint64[S []E, E ~uint64](s S) Value
- func SliceUint8[S []E, E ~uint8](s S) Value
- func String(v string) Value
- func Uint16(v uint16) Value
- func Uint32(v uint32) Value
- func Uint64(v uint64) Value
- func Uint8(v uint8) Value
- func UnmarshalValue(b []byte, arch byte, baseType basetype.BaseType, ...) (Value, error)
- func (v Value) Align(t basetype.BaseType) bool
- func (v Value) Any() any
- func (v Value) Bool() bool
- func (v Value) Float32() float32
- func (v Value) Float64() float64
- func (v Value) Int16() int16
- func (v Value) Int32() int32
- func (v Value) Int64() int64
- func (v Value) Int8() int8
- func (v Value) MarshalAppend(b []byte, arch byte) ([]byte, error)
- func (v Value) SliceBool() []bool
- func (v Value) SliceFloat32() []float32
- func (v Value) SliceFloat64() []float64
- func (v Value) SliceInt16() []int16
- func (v Value) SliceInt32() []int32
- func (v Value) SliceInt64() []int64
- func (v Value) SliceInt8() []int8
- func (v Value) SliceString() []string
- func (v Value) SliceUint16() []uint16
- func (v Value) SliceUint32() []uint32
- func (v Value) SliceUint64() []uint64
- func (v Value) SliceUint8() []uint8
- func (v Value) String() string
- func (v Value) Type() Type
- func (v Value) Uint16() uint16
- func (v Value) Uint16z() uint16
- func (v Value) Uint32() uint32
- func (v Value) Uint32z() uint32
- func (v Value) Uint64() uint64
- func (v Value) Uint64z() uint64
- func (v Value) Uint8() uint8
- func (v Value) Uint8z() uint8
- func (v Value) Valid(t basetype.BaseType) bool
- type Version
Constants ¶
const ( MesgDefinitionMask = 0b01000000 // Mask for determining if the message type is a message definition. MesgNormalHeaderMask = 0b00000000 // Mask for determining if the message type is a normal message data . MesgCompressedHeaderMask = 0b10000000 // Mask for determining if the message type is a compressed timestamp message data. LocalMesgNumMask = 0b00001111 // Mask for mapping normal message data to the message definition. CompressedLocalMesgNumMask = 0b01100000 // Mask for mapping compressed timestamp message data to the message definition. Used with CompressedBitShift. CompressedTimeMask = 0b00011111 // Mask for measuring time offset value from header. Compressed timestamp is using 5 least significant bits (lsb) of header DevDataMask = 0b00100000 // Mask for determining if a message contains developer fields. CompressedBitShift = 5 // Used for right-shifting the 5 least significant bits (lsb) of compressed time. DefaultFileHeaderSize byte = 14 // The preferred size is 14 DataTypeFIT string = ".FIT" // FIT is a constant string ".FIT" FieldNumTimestamp = 253 // Field Num for timestamp across all defined messages in the profile. )
const ( ErrProtocolVersionNotSupported = errorString("protocol version not supported") MajorVersionShift = 4 MajorVersionMask = 0x0F << MajorVersionShift MinorVersionMask = 0x0F V1 Version = 1 << MajorVersionShift // V1 is Version 1.0 V2 Version = 2 << MajorVersionShift // V2 is Version 2.0 Vmax = V2 // Vmax is an alias for the current latest version. )
const ErrProtocolViolation = errorString("protocol violation")
const ErrTypeNotSupported = errorString("type is not supported")
const MaxBytesPerMessage = 1 + (255*255)*2
Header + ((max n Fields) * (n value)) + ((max n DeveloperFields) * (n value))
const MaxBytesPerMessageDefinition = 5 + 1 + (255 * 3) + 1 + (255 * 3)
Header + Reserved + Architecture + MesgNum (2 bytes) + n Fields + (Max n Fields * 3) + n DevFields + (Max n DevFields * 3).
Variables ¶
This section is empty.
Functions ¶
func CreateMessageDefinitionTo ¶ added in v0.8.4
func CreateMessageDefinitionTo(target *MessageDefinition, mesg *Message)
CreateMessageDefinitionTo create MessageDefinition base on given Message and put it at target object to avoid allocation. It will panic if either target or mesg is nil. And mesg must be validated first, for instance if field.Value's size is more than 255 bytes, overflow will occurs.
func LocalMesgNum ¶
LocalMesgNum extracts LocalMesgNum from message header.
func Sizeof ¶ added in v0.12.0
Sizeof returns the size of val in bytes. For every string in Value, if the last index of the string is not '\x00', size += 1.
func VersionMajor ¶
VersionMajor returns major value of given version
func VersionMinor ¶
VersionMinor returns minor value of given version
Types ¶
type Component ¶
type Component struct { FieldNum byte Accumulate bool Bits byte // bit value max 32 Scale float64 Offset float64 }
Component is a way of compressing one or more fields into a bit field expressed in a single containing field. The component can be expanded as a main Field in a Message or to update the value of the destination main Field.
type DeveloperField ¶
type DeveloperField struct { Num byte DeveloperDataIndex byte Size byte NativeMesgNum typedef.MesgNum NativeFieldNum byte BaseType basetype.BaseType Name string Units string Value Value }
Developer Field is a way to add custom data fields to existing messages. Developer Data Fields can be added to any message at runtime by providing a self-describing field definition. Developer Data Fields are also used by the Connect IQ FIT Contributor library, allowing Connect IQ apps and data fields to include custom data in FIT Activity files during the recording of activities. [Added since protocol version 2.0]
NOTE: If Developer Field contains a valid NativeMesgNum and NativeFieldNum, the value should be treated as native value (scale, offset, etc shall apply).
func (DeveloperField) Clone ¶
func (f DeveloperField) Clone() DeveloperField
Clone clones DeveloperField
type DeveloperFieldDefinition ¶
type DeveloperFieldDefinition struct { Num byte // Map to the `field_definition_number` of a `field_description` Message. Size byte // Size (in bytes) of the specified FIT message’s field DeveloperDataIndex byte // Maps to the `developer_data_index“ of a `developer_data_id` Message }
FieldDefinition is the definition of the upcoming developer field within the message's structure.
type FIT ¶ added in v0.12.0
type FIT struct { FileHeader FileHeader // File Header contains either 12 or 14 bytes Messages []Message // Messages. CRC uint16 // Cyclic Redundancy Check 16-bit value to ensure the integrity of the messages. }
FIT represents a structure for FIT Files.
func (*FIT) WithMessages ¶ added in v0.12.0
WithMessages set Messages and return the pointer to the FIT.
type Field ¶
type Field struct { // PERF: Embedding the struct as a pointer to avoid runtime duffcopy when creating a field since FieldBase should not be altered. *FieldBase // Value holds any primitive-type single value (or slice value) in a form of proto.Value. // We use proto.Value instead of interface{} because interface{} is heap-allocated, whereas proto.Value is not. Value Value // A flag to detect whether this field is generated through component expansion. IsExpandedField bool }
Field represents the full representation of a field, as specified in the Global FIT Profile.
func (*Field) SubFieldSubtitution ¶
SubFieldSubstitution returns any sub-field that can substitute the properties interpretation of the parent Field (Dynamic Field).
type FieldBase ¶
type FieldBase struct { Name string // Defined in the Global FIT profile for the specified FIT message, otherwise its a manufaturer specific name (defined by manufacturer). Num byte // Defined in the Global FIT profile for the specified FIT message, otherwise its a manufaturer specific number (defined by manufacturer). (255 == invalid) Type profile.ProfileType // Type is defined type that serves as an abstraction layer above base types (primitive-types), e.g. DateTime is a time representation in uint32. BaseType basetype.BaseType // BaseType is the base of the ProfileType. E.g. profile.DateTime -> basetype.Uint32. Array bool // Flag whether the value of this field is an array Accumulate bool // Flag to indicate if the value of the field is accumulable. Scale float64 // A scale or offset specified in the FIT profile for binary fields (sint/uint etc.) only. the binary quantity is divided by the scale factor and then the offset is subtracted. (default: 1) Offset float64 // A scale or offset specified in the FIT profile for binary fields (sint/uint etc.) only. the binary quantity is divided by the scale factor and then the offset is subtracted. (default: 0) Units string // Units of the value, such as m (meter), m/s (meter per second), s (second), etc. Components []Component // List of components SubFields []SubField // List of sub-fields }
FieldBase acts as a fundamental representation of a field as defined in the Global FIT Profile. The value of this representation should not be altered, except in the case of an unknown field.
type FieldDefinition ¶
type FieldDefinition struct { Num byte // The field definition number Size byte // The size of the upcoming value BaseType basetype.BaseType // The type of the upcoming value to be represented }
FieldDefinition is the definition of the upcoming field within the message's structure.
type FileHeader ¶
type FileHeader struct { Size byte // Header size either 12 (legacy) or 14. ProtocolVersion byte // The FIT Protocol version which is being used to encode the FIT file. ProfileVersion uint16 // The FIT Profile Version (associated with data defined in Global FIT Profile). DataSize uint32 // The size of the messages in bytes (this field will be automatically updated by the encoder) DataType string // ".FIT" (a string constant) CRC uint16 // Cyclic Redundancy Check 16-bit value to ensure the integrity if the header. (this field will be automatically updated by the encoder) }
FileHeader is a FIT's FileHeader with either 12 bytes size without CRC or a 14 bytes size with CRC, while 14 bytes size is the preferred size.
func (FileHeader) MarshalAppend ¶ added in v0.15.0
func (h FileHeader) MarshalAppend(b []byte) ([]byte, error)
MarshalAppend appends the FIT format encoding of FileHeader to b, returning the result.
func (FileHeader) MarshalBinary ¶
func (h FileHeader) MarshalBinary() ([]byte, error)
MarshalBinary returns the FIT format encoding of FileHeader and nil error.
type Message ¶
type Message struct { Header byte // Message Header serves to distinguish whether the message is a Normal Data or a Compressed Timestamp Data. Unlike MessageDefinition, Message's Header should not contain Developer Data Flag. Num typedef.MesgNum // Global Message Number defined in Global FIT Profile, except number within range 0xFF00 - 0xFFFE are manufacturer specific number. Reserved byte // Currently undetermined; the default value is 0. Architecture byte // Architecture type / Endianness. Must be the same Fields []Field // List of Field DeveloperFields []DeveloperField // List of DeveloperField }
Message is a FIT protocol message containing the data defined in the Message Definition
func (*Message) FieldByNum ¶
FieldByNum returns a pointer to the Field in a Message, if not found return nil.
func (*Message) FieldValueByNum ¶ added in v0.1.0
FieldValueByNum returns the value of the Field in a Messsage, if not found return nil.
func (Message) MarshalAppend ¶ added in v0.15.0
MarshalAppend appends the FIT format encoding of Message to b, returning the result.
func (Message) MarshalBinary ¶
MarshalBinary returns the FIT format encoding of Message and any error encountered during marshal.
func (*Message) RemoveFieldByNum ¶
RemoveFieldByNum removes Field in a Message by num.
func (Message) WithDeveloperFields ¶
func (m Message) WithDeveloperFields(developerFields ...DeveloperField) Message
WithFields puts the provided fields into the message's fields.
func (Message) WithFieldValues ¶
WithFieldValues assigns the values of the targeted fields with the given map, where map[byte]any represents the field numbers and their respective values. If the specified fieldNum does not have a corresponding target match in the fields, no value will be assigned.
func (Message) WithFields ¶
WithFields puts the provided fields into the message's fields.
type MessageDefinition ¶
type MessageDefinition struct { Header byte // The message definition header with mask 0b01000000. Reserved byte // Currently undetermined; the default value is 0. Architecture byte // The Byte Order to be used to decode the values of both this message definition and the upcoming message. (0: Little-Endian, 1: Big-Endian) MesgNum typedef.MesgNum // Global Message Number defined by factory (retrieved from Profile.xslx). (endianness of this 2 Byte value is defined in the Architecture byte) FieldDefinitions []FieldDefinition // List of the field definition DeveloperFieldDefinitions []DeveloperFieldDefinition // List of the developer field definition (only if Developer Data Flag is set in Header) }
MessageDefinition is the definition of the upcoming data messages.
func CreateMessageDefinition ¶
func CreateMessageDefinition(mesg *Message) (mesgDef MessageDefinition)
CreateMessageDefinition creates new MessageDefinition base on given Message. It will panic if mesg is nil. And mesg must be validated first, for instance if field.Value's size is more than 255 bytes, overflow will occurs.
func (MessageDefinition) Clone ¶
func (m MessageDefinition) Clone() MessageDefinition
Clone clones MessageDefinition
func (MessageDefinition) MarshalAppend ¶ added in v0.15.0
func (m MessageDefinition) MarshalAppend(b []byte) ([]byte, error)
MarshalAppend appends the FIT format encoding of MessageDefinition to b, returning the result.
func (MessageDefinition) MarshalBinary ¶
func (m MessageDefinition) MarshalBinary() ([]byte, error)
MarshalBinary returns the FIT format encoding of MessageDefinition and nil error.
type SubField ¶
type SubField struct { Name string Type profile.ProfileType Scale float64 Offset float64 Units string Maps []SubFieldMap Components []Component }
SubField is a dynamic interpretation of the main Field in a Message when the SubFieldMap mapping match. See SubFieldMap's docs.
type SubFieldMap ¶
SubFieldMap is the mapping between SubField and and the corresponding main Field in a Message. When any Field in a Message has Field.Num == RefFieldNum and Field.Value == RefFieldValue, then the SubField containing this mapping can be interpreted as the main Field's properties (name, scale, type etc.)
type Type ¶ added in v0.12.0
type Type byte
Type is Value's type
const ( TypeInvalid Type = iota TypeBool TypeInt8 TypeUint8 TypeInt16 TypeUint16 TypeInt32 TypeUint32 TypeInt64 TypeUint64 TypeFloat32 TypeFloat64 TypeString TypeSliceBool TypeSliceInt8 TypeSliceUint8 TypeSliceInt16 TypeSliceUint16 TypeSliceInt32 TypeSliceUint32 TypeSliceInt64 TypeSliceUint64 TypeSliceFloat32 TypeSliceFloat64 TypeSliceString )
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is protocol validator
func NewValidator ¶
NewValidator creates protocol validator base on given version.
func (*Validator) ProtocolVersion ¶ added in v0.9.0
ProtocolVersion returns the protocol version that this validator validates.
func (*Validator) SetProtocolVersion ¶ added in v0.9.0
SetProtocolVersion sets new protocol version to validate.
func (*Validator) ValidateMessageDefinition ¶
func (p *Validator) ValidateMessageDefinition(mesgDef *MessageDefinition) error
ValidateMessageDefinition validates whether the message definition contains unsupported data for the targeted version.
type Value ¶ added in v0.12.0
type Value struct {
// contains filtered or unexported fields
}
Value is a zero alloc implementation value that hold any FIT protocol value (value of primitive-types or slice of primitive-types).
To compare two Values of not known type, compare the results of the Any method. Using == on two Values is disallowed.
func Any ¶ added in v0.12.0
Any converts any value into Value. If the given v is not a primitive-type value (or a slice of primitive-type) it will determine it using reflection, and if it's a non-primitive-type slice it will make 1 alloc.
- If v is not supported such as int, uint, []int, []uint, []any, slice with zero len, etc. Value with TypeInvalid is returned.
- If v is a primitive-type slice, this will take ownership of v, and the caller should not use v after this call.
func SliceBool ¶ added in v0.12.0
SliceBool converts []bool as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceFloat32 ¶ added in v0.12.0
SliceFloat32 converts []float32 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceFloat64 ¶ added in v0.12.0
SliceFloat64 converts []float64 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceInt16 ¶ added in v0.12.0
SliceInt16 converts []int16 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceInt32 ¶ added in v0.12.0
SliceInt32 converts []int32 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceInt64 ¶ added in v0.12.0
SliceInt64 converts []int64 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceInt8 ¶ added in v0.12.0
SliceInt8 converts []int8 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceString ¶ added in v0.12.0
SliceString converts []string as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceUint16 ¶ added in v0.12.0
SliceUint16 converts []uint16 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceUint32 ¶ added in v0.12.0
SliceUint32 converts []uint32 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceUint64 ¶ added in v0.12.0
SliceUint64 converts []uint64 as Value. This takes ownership of s, and the caller should not use s after this call.
func SliceUint8 ¶ added in v0.12.0
SliceUint8 converts []uint8 as Value. This takes ownership of s, and the caller should not use s after this call.
func UnmarshalValue ¶ added in v0.15.0
func UnmarshalValue(b []byte, arch byte, baseType basetype.BaseType, profileType profile.ProfileType, isArray bool) (Value, error)
UnmarshalValue unmarshals b into a proto.Value. The caller should ensure that the len(b) matches its corresponding base type's size, otherwise it might panic.
func (Value) Any ¶ added in v0.12.0
Any returns Value's underlying value. If the underlying value is a slice, the caller takes ownership of that slice value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) Bool ¶ added in v0.12.0
Bool returns Value as bool, if it's not a valid bool value, it returns false.
func (Value) Float32 ¶ added in v0.12.0
Float32 returns Value as float32, if it's not a valid float32 value, it returns basetype.Float32Invalid (0xFFFFFFFF) in float32 value.
func (Value) Float64 ¶ added in v0.12.0
Float64 returns Value as float64, if it's not a valid float64 value, it returns basetype.Float64Invalid (0xFFFFFFFFFFFFFFFF) in float64 value.
func (Value) Int16 ¶ added in v0.12.0
Int16 returns Value as int16, if it's not a valid int16 value, it returns basetype.Sint16Invalid (0x7FFF).
func (Value) Int32 ¶ added in v0.12.0
Int32 returns Value as int32, if it's not a valid int32 value, it returns basetype.Sint32Invalid (0x7FFFFFFF).
func (Value) Int64 ¶ added in v0.12.0
Int64 returns Value as int64, if it's not a valid int64 value, it returns basetype.Sint64Invalid (0x7FFFFFFFFFFFFFFF).
func (Value) Int8 ¶ added in v0.12.0
Int8 returns Value as int8, if it's not a valid int8 value, it returns basetype.Sint8Invalid (0x7F).
func (Value) MarshalAppend ¶ added in v0.15.0
MarshalAppend appends the FIT format encoding of Value to b. Returning the result. If arch is 0, marshal in Little-Endian, otherwise marshal in Big-Endian.
func (Value) SliceBool ¶ added in v0.12.0
SliceBool returns Value as []bool, if it's not a valid []bool value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceFloat32 ¶ added in v0.12.0
SliceFloat32 returns Value as []float32, if it's not a valid []float32 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceFloat64 ¶ added in v0.12.0
SliceFloat64 returns Value as []float64, if it's not a valid []float64 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceInt16 ¶ added in v0.12.0
SliceInt16 returns Value as []int16, if it's not a valid []int16 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceInt32 ¶ added in v0.12.0
SliceInt32 returns Value as []int32, if it's not a valid []int32 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceInt64 ¶ added in v0.12.0
SliceInt64 returns Value as []int64, if it's not a valid []int64 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceInt8 ¶ added in v0.12.0
SliceInt8 returns Value as []int8, if it's not a valid []int8 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceString ¶ added in v0.12.0
SliceString returns Value as []string, if it's not a valid []string value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceUint16 ¶ added in v0.12.0
SliceUint16 returns Value as []uint16, if it's not a valid []uint16 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceUint32 ¶ added in v0.12.0
SliceUint32 returns Value as []uint32, if it's not a valid []uint32 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceUint64 ¶ added in v0.12.0
SliceUint64 returns Value as []uint64, if it's not a valid []uint64 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) SliceUint8 ¶ added in v0.12.0
SliceUint8 returns Value as []uint8, if it's not a valid []uint8 value, it returns nil. The caller takes ownership of the returned value, so Value should no longer be used after this call, except the returned value is copied and the copied value is used instead.
func (Value) String ¶ added in v0.12.0
String returns Value as string, if it's not a valid string value, it returns basetype.StringInvalid. This should not be treated as a Go's String method, use Any() if you want to print the underlying value.
func (Value) Uint16 ¶ added in v0.12.0
Uint16 returns Value as uint16, if it's not a valid uint16 value, it returns basetype.Uint16Invalid (0xFFFF).
func (Value) Uint16z ¶ added in v0.12.0
Uint16z returns Value as uint16, if it's not a valid uint16 value, it returns basetype.Uint16zInvalid (0).
func (Value) Uint32 ¶ added in v0.12.0
Uint32 returns Value as uint32, if it's not a valid uint32 value, it returns basetype.Uint32Invalid (0xFFFFFFFF).
func (Value) Uint32z ¶ added in v0.12.0
Uint32z returns Value as uint32, if it's not a valid uint32 value, it returns basetype.Uint32zInvalid (0).
func (Value) Uint64 ¶ added in v0.12.0
Uint64 returns Value as uint64, if it's not a valid uint64 value, it returns basetype.Uint64Invalid (0xFFFFFFFFFFFFFFFF).
func (Value) Uint64z ¶ added in v0.12.0
Uint64z returns Value as uint64, if it's not a valid uint64 value, it returns basetype.Uint64Invalid (0).
func (Value) Uint8 ¶ added in v0.12.0
Uint8 returns Value as uint8, if it's not a valid uint8 value, it returns basetype.Uint8Invalid (0xFF).
func (Value) Uint8z ¶ added in v0.12.0
Uint8z returns Value as uint8, if it's not a valid uint8 value, it returns basetype.Uint8zInvalid (0).
func (Value) Valid ¶ added in v0.13.1
Valid checks whether the Value is valid based on given basetype. This does not verify whether the Type of the Value aligns with the provided BaseType. For slices, even though only one element is valid, the Value will be counted a valid value.
Special case: bool or slice of bool will always be valid since bool type is often used as a flag and there are only two possibility (true/false).