Specifies that a type is capable of raw struct serialization and deserialization.
More...
template<typename T>
std::span<uint8_t> out, T&& value) {
typename Struct<typename std::remove_cvref_t<T>>;
{
} -> std::convertible_to<std::string_view>;
{
} -> std::convertible_to<size_t>;
{
} -> std::convertible_to<std::string_view>;
{
Struct<typename std::remove_cvref_t<T>>
::Unpack(
in)
} -> std::same_as<typename std::remove_cvref_t<T>>;
Struct<typename std::remove_cvref_t<T>>
::Pack(out, std::forward<T>(value));
}
Specifies that a type is capable of raw struct serialization and deserialization.
Definition: Struct.h:67
constexpr auto in(type t, int set) -> bool
Definition: core.h:611
Struct serialization template.
Definition: Struct.h:37
static frc::DCMotor Unpack(std::span< const uint8_t > data)
static constexpr std::string_view GetTypeString()
Definition: DCMotorStruct.h:14
static constexpr std::string_view GetSchema()
Definition: DCMotorStruct.h:16
static constexpr size_t GetSize()
Definition: DCMotorStruct.h:15
static void Pack(std::span< uint8_t > data, const frc::DCMotor &value)
Specifies that a type is capable of raw struct serialization and deserialization.
This is designed for serializing small fixed-size data structures in the fastest and most compact means possible. Serialization consists of writing values into a mutable std::span and deserialization consists of reading values from an immutable std::span.
Implementations must define a template specialization for wpi::Struct with T being the type that is being serialized/deserialized, with the following static members (as enforced by this concept):
- std::string_view GetTypeString(): function that returns the type string
- size_t GetSize(): function that returns the structure size in bytes
- std::string_view GetSchema(): function that returns the struct schema
- T Unpack(std::span<const uint8_t>): function for deserialization
- void Pack(std::span<uint8_t>, T&& value): function for serialization
If possible, the GetTypeString(), GetSize(), and GetSchema() functions should be marked constexpr. GetTypeString() and GetSchema() may return types other than std::string_view, as long as the return value is convertible to std::string_view.
If the struct has nested structs, implementations should also meet the requirements of HasNestedStruct<T>.