auth 0.0.1
Authenticated computation with C++26 modules
Loading...
Searching...
No Matches
auth::reader Struct Referenceexport

Reads checked fields from borrowed bytes, advancing a byte offset. More...

Public Member Functions

template<std::unsigned_integral T>
void field (T &value)
 Reads a little-endian unsigned integer, or a one-byte boolean.
template<class T, std::size_t N>
void field (std::array< T, N > &value)
 Reads each array element in order; no length prefix is consumed.
template<class... Ts>
void field (std::variant< Ts... > &value)
 Reads a variant's index and constructs and fills its selected alternative.
template<class T>
void field (std::unique_ptr< T > &value)
 Allocates and reads a boxed value, replacing the pointer on success.
template<class T>
requires requires(T& v, reader& s) { v.serialize(s); }
void field (T &value)
 Invokes a custom type's serialize method through a mutable reference.
template<class... Ts>
void operator() (Ts &... values)
 Reads fields from left to right using the matching field overloads.

Public Attributes

std::span< const std::uint8_t > data
 Borrowed input bytes.
std::size_t position = 0
 Offset of the next unread byte.

Static Public Attributes

static constexpr bool reading = true
 Selects the reading path in serializers.

Detailed Description

Reads checked fields from borrowed bytes, advancing a byte offset.

Precondition
position is at most data.size().
Note
Input storage must remain valid and unchanged during reading. A failed read may modify the cursor and destination; decode uses a local reader.

Definition at line 105 of file serialization.ccm.

Member Function Documentation

◆ field() [1/5]

template<class T, std::size_t N>
void auth::reader::field ( std::array< T, N > & value)
inline

Reads each array element in order; no length prefix is consumed.

Parameters
[out]valueFixed-size array to fill.

Definition at line 133 of file serialization.ccm.

◆ field() [2/5]

template<class T>
void auth::reader::field ( std::unique_ptr< T > & value)
inline

Allocates and reads a boxed value, replacing the pointer on success.

Parameters
[out]valueOwning pointer to a default-constructible payload.

Definition at line 153 of file serialization.ccm.

◆ field() [3/5]

template<class... Ts>
void auth::reader::field ( std::variant< Ts... > & value)
inline

Reads a variant's index and constructs and fills its selected alternative.

Parameters
[out]valueVariant whose alternatives must be default-constructible.
Exceptions
auth_errorIf the index is invalid or the encoding is malformed.

Definition at line 142 of file serialization.ccm.

◆ field() [4/5]

template<class T>
requires requires(T& v, reader& s) { v.serialize(s); }
void auth::reader::field ( T & value)
inline

Invokes a custom type's serialize method through a mutable reference.

Parameters
[in,out]valueValue whose serializer reads its fields from this stream.
Note
A private serializer may grant friendship to reader.

Definition at line 164 of file serialization.ccm.

◆ field() [5/5]

template<std::unsigned_integral T>
void auth::reader::field ( T & value)
inline

Reads a little-endian unsigned integer, or a one-byte boolean.

Parameters
[out]valueDecoded value.
Exceptions
auth_errorIf the input is truncated or a boolean is not 0 or 1.

Definition at line 115 of file serialization.ccm.

◆ operator()()

template<class... Ts>
void auth::reader::operator() ( Ts &... values)
inline

Reads fields from left to right using the matching field overloads.

Parameters
[out]valuesFields to decode.

Definition at line 170 of file serialization.ccm.


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