Size / write / read for one type T.
More...
#include <StormByte/serializable.hxx>
|
| static ByteSize | Size (const T &data) noexcept |
| | Serialized size of data.
|
| |
| static BinaryData | Write (const T &data) noexcept |
| | Encodes data to a little-endian blob.
|
| |
| static Expected< T, DeserializeError > | Read (std::span< const std::byte > data) noexcept |
| | Decodes T from the start of data.
|
| |
template<typename T>
struct StormByte::Detail::Codec< T >
Size / write / read for one type T.
- Template Parameters
-
Primary template is intentionally unusable. Specialize the whole struct (all three members) for a type that is not optional, pair, container or trivially copyable.
template<>
};
DLL-boundary-safe owned contiguous sequence of std::byte.
Definition binary_data.hxx:106
Count of octets (uint64_t storage).
Definition byte_size.hxx:103
Count of abstract units (uint64_t storage).
Definition size.hxx:100
std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Safe::Shared< E > >, std::expected< T, Safe::Shared< E > > > Expected
std::expected alias with reference and shared-error handling.
Definition expected.hxx:66
Size / write / read for one type T.
Definition serializable.hxx:107
static BinaryData Write(const T &data) noexcept
Encodes data to a little-endian blob.
Definition serializable.hxx:125
static Expected< T, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes T from the start of data.
Definition serializable.hxx:137
- Note
- The three members must agree with each other.
Size(v) must equal Write(v).size() as a byte count. Read consumes a prefix of that length; leftover bytes belong to the caller.
◆ Read()
Decodes T from the start of data.
- Parameters
-
| [in] | data | Input span; may be longer than one value. |
- Returns
- Value, or StormByte::DeserializeError.
◆ Size()
Serialized size of data.
- Parameters
-
| [in] | data | Value to measure. |
- Returns
- Size in bytes as ByteSize.
◆ Write()
Encodes data to a little-endian blob.
- Parameters
-
- Returns
- Blob owned by Base. No framing beyond what
T itself needs.
The documentation for this struct was generated from the following file: