Crunch
A Message Definition Language for Getting Things Right
Loading...
Searching...
No Matches
Crunch::serdes::StaticLayout< Alignment > Struct Template Reference

A deterministic, fixed-size binary serialization policy. More...

#include <crunch_static_layout.hpp>

Static Public Member Functions

static constexpr Crunch::Format GetFormat () noexcept
 Gets the Crunch format corresponding to the alignment.
 
template<typename Message >
static constexpr std::size_t Size () noexcept
 Calculates the serialized size of a message.
 
template<typename Message >
static constexpr std::size_t Serialize (const Message &msg, std::span< std::byte > output) noexcept
 Serializes a message into the output buffer.
 
template<typename Message >
static constexpr auto Deserialize (std::span< const std::byte > input, Message &msg) noexcept -> std::optional< Error >
 Deserializes a message from the input buffer.
 

Detailed Description

template<std::size_t Alignment = 1>
struct Crunch::serdes::StaticLayout< Alignment >

A deterministic, fixed-size binary serialization policy.

Member Function Documentation

◆ Deserialize()

template<std::size_t Alignment = 1>
template<typename Message >
static constexpr auto Crunch::serdes::StaticLayout< Alignment >::Deserialize ( std::span< const std::byte >  input,
Message &  msg 
) -> std::optional<Error>
inlinestaticconstexprnoexcept

Deserializes a message from the input buffer.

Template Parameters
MessageThe message type.
Parameters
inputThe input buffer.
msgThe message object to populate.
Returns
std::nullopt on success, or an Error on failure.

◆ GetFormat()

template<std::size_t Alignment = 1>
static constexpr Crunch::Format Crunch::serdes::StaticLayout< Alignment >::GetFormat ( )
inlinestaticconstexprnoexcept

Gets the Crunch format corresponding to the alignment.

Returns
The format enum.

◆ Serialize()

template<std::size_t Alignment = 1>
template<typename Message >
static constexpr std::size_t Crunch::serdes::StaticLayout< Alignment >::Serialize ( const Message &  msg,
std::span< std::byte >  output 
)
inlinestaticconstexprnoexcept

Serializes a message into the output buffer.

Template Parameters
MessageThe message type.
Parameters
msgThe message to serialize.
outputThe output buffer.
Returns
The number of bytes written.

◆ Size()

template<std::size_t Alignment = 1>
template<typename Message >
static constexpr std::size_t Crunch::serdes::StaticLayout< Alignment >::Size ( )
inlinestaticconstexprnoexcept

Calculates the serialized size of a message.

Template Parameters
MessageThe message type.
Returns
The size in bytes.

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