feat: add struct tags to struct types

This commit is contained in:
Jonathan Barrow 2024-07-03 23:39:23 -04:00
parent 2309a6d409
commit 182418f999
No known key found for this signature in database
GPG key ID: E86E9FE9049C741F
6 changed files with 14 additions and 14 deletions

View file

@ -19,10 +19,10 @@ func RegisterDataHolderType(name string, rvType RVType) {
// `Data` Structure, but this is not always the case. The contained Structures name & length are sent with the
// Structure body, so the receiver can properly decode it.
type AnyDataHolder struct {
TypeName String
Length1 UInt32 // Length of ObjectData + Length2
Length2 UInt32 // Length of ObjectData
ObjectData RVType
TypeName String `json:"type_name" db:"type_name" bson:"type_name" xml:"TypeName"`
Length1 UInt32 `json:"length1" db:"length1" bson:"length1" xml:"Length1"` // * Length of ObjectData + Length2
Length2 UInt32 `json:"length2" db:"length2" bson:"length2" xml:"Length2"` // * Length of ObjectData
ObjectData RVType `json:"object_data" db:"object_data" bson:"object_data" xml:"ObjectData"`
}
// WriteTo writes the AnyDataHolder to the given writable

View file

@ -9,7 +9,7 @@ import (
// Contains version info for Structures used in verbose RMC messages.
type ClassVersionContainer struct {
Structure
ClassVersions Map[String, UInt16]
ClassVersions Map[String, UInt16] `json:"class_versions" db:"class_versions" bson:"class_versions" xml:"ClassVersions"`
}
// WriteTo writes the ClassVersionContainer to the given writable

View file

@ -9,8 +9,8 @@ import (
// Holds information about how to make queries which may return large data.
type ResultRange struct {
Structure
Offset UInt32 // Offset into the dataset
Length UInt32 // Number of items to return
Offset UInt32 `json:"offset" db:"offset" bson:"offset" xml:"Offset"` // * Offset into the dataset
Length UInt32 `json:"length" db:"length" bson:"length" xml:"Length"` // * Number of items to return
}
// WriteTo writes the ResultRange to the given writable

View file

@ -9,10 +9,10 @@ import (
// Contains the locations and data of Rendez-Vous connection.
type RVConnectionData struct {
Structure
StationURL StationURL
SpecialProtocols List[UInt8]
StationURLSpecialProtocols StationURL
Time DateTime
StationURL StationURL `json:"station_url" db:"station_url" bson:"station_url" xml:"StationURL"`
SpecialProtocols List[UInt8] `json:"special_protocols" db:"special_protocols" bson:"special_protocols" xml:"SpecialProtocols"`
StationURLSpecialProtocols StationURL `json:"station_url_special_protocols" db:"station_url_special_protocols" bson:"station_url_special_protocols" xml:"StationURLSpecialProtocols"`
Time DateTime `json:"time" db:"time" bson:"time" xml:"Time"`
}
// WriteTo writes the RVConnectionData to the given writable

View file

@ -7,7 +7,7 @@ import (
// Structure represents a Quazal Rendez-Vous/NEX Structure (custom class) base struct.
type Structure struct {
StructureVersion uint8
StructureVersion uint8 `json:"structure_version" db:"structure_version" bson:"structure_version" xml:"StructureVersion"`
}
// ExtractHeaderFrom extracts the structure header from the given readable

View file

@ -17,8 +17,8 @@ func RegisterVariantType(id UInt8, rvType RVType) {
// Variant is an implementation of rdv::Variant.
// This type can hold many other types, denoted by a type ID.
type Variant struct {
TypeID UInt8
Type RVType
TypeID UInt8 `json:"type_id" db:"type_id" bson:"type_id" xml:"TypeID"`
Type RVType `json:"type" db:"type" bson:"type" xml:"Type"`
}
// WriteTo writes the Variant to the given writable