StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Detail::Codec< Safe::String > Struct Reference

StormByte::Detail::Codec specialization for StormByte::Safe::String. More...

#include <StormByte/serializable.hxx>

Static Public Member Functions

static ByteSize Size (const Safe::String &data) noexcept
 Serialized size of data.
static Safe::Binary Write (const Safe::String &data) noexcept
 Encodes data.
static Expected< Safe::String, DeserializeError > Read (std::span< const std::byte > data) noexcept
 Decodes a StormByte::Safe::String from the start of data.

Detailed Description

StormByte::Detail::Codec specialization for StormByte::Safe::String.

Same wire as std::string: uint64 byte count (LE) + raw bytes. Embedded NUL bytes are preserved. A null StormByte::Safe::String is written as an empty payload (operator std::string). Decode always yields a non-null buffer ("" when the payload is empty).

Member Function Documentation

◆ Read()

Expected< Safe::String, DeserializeError > StormByte::Detail::Codec< Safe::String >::Read ( std::span< const std::byte > data)
staticnoexcept

Decodes a StormByte::Safe::String from the start of data.

Parameters
dataInput span.
Returns
Value, or StormByte::DeserializeError.

◆ Size()

ByteSize StormByte::Detail::Codec< Safe::String >::Size ( const Safe::String & data)
staticnoexcept

Serialized size of data.

Parameters
dataValue to measure.
Returns
Size in bytes as ByteSize.

◆ Write()

Safe::Binary StormByte::Detail::Codec< Safe::String >::Write ( const Safe::String & data)
staticnoexcept

Encodes data.

Parameters
dataValue to encode.
Returns
Blob owned by Base.

The documentation for this struct was generated from the following file: