|
template<messages::CrunchMessage Message, typename Integrity , typename Serdes >
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message> |
| consteval auto | GetBufferSize () noexcept -> std::size_t |
| | Compile-time calculation of the size of a buffer for a given message, integrity, and serdes combination.
|
| |
template<typename Message >
requires messages::CrunchMessage<Message> |
| constexpr auto | Validate (const Message &message) noexcept -> std::optional< Error > |
| | Forward declaration of Validate to enable recursion in ValidateField.
|
| |
| template<typename T > |
| constexpr std::optional< Error > | ValidateField (const T &field) |
| | Helper to validate a single field.
|
| |
template<typename Integrity , typename Serdes , messages::CrunchMessage Message, std::size_t N>
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message> |
| std::size_t | SerializeWithoutValidation (std::array< std::byte, N > &buffer, const Message &message) noexcept |
| | Serializes the message without any validation checks.
|
| |
template<typename Integrity , typename Serdes , messages::CrunchMessage Message, std::size_t N>
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message> |
| auto | Serialize (std::array< std::byte, N > &buffer, const Message &message) noexcept -> std::expected< std::size_t, Error > |
| | implementation of Serialize.
|
| |
template<typename Integrity , typename Serdes , typename Message >
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message> && messages::CrunchMessage<Message> |
| auto | Deserialize (std::span< const std::byte > buffer, Message &message) noexcept -> std::optional< Error > |
| | implementation of Deserialize.
|
| |
Internal implementation details for Crunch's public API.
template<typename Integrity , typename Serdes , typename Message >
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message> && messages::CrunchMessage<Message>
| auto Crunch::detail::Deserialize |
( |
std::span< const std::byte > |
buffer, |
|
|
Message & |
message |
|
) |
| -> std::optional<Error> |
|
noexcept |
implementation of Deserialize.
First, the integrity policy is executed to validate the buffer. Then, the header is deserialized. Finally, the payload is delegated to the Serdes policy for deserialization.
- Template Parameters
-
| Integrity | The integrity policy to use. |
| Serdes | The serialization policy to use. |
| Message | The message type to deserialize into. |
- Parameters
-
| buffer | The buffer to deserialize from. |
| message | The message object to populate. |
- Returns
- std::nullopt on success, or an Error if integrity or deserialization fails.
template<messages::CrunchMessage Message, typename Integrity , typename Serdes >
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message>
| consteval auto Crunch::detail::GetBufferSize |
( |
| ) |
-> std::size_t |
|
noexcept |
Compile-time calculation of the size of a buffer for a given message, integrity, and serdes combination.
- Template Parameters
-
| Message | The message type to calculate the buffer size for. |
| Integrity | The integrity policy to use. |
| Serdes | The serialization policy to use. |
- Returns
- The size of the buffer in bytes.
template<typename Integrity , typename Serdes , messages::CrunchMessage Message, std::size_t N>
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message>
| auto Crunch::detail::Serialize |
( |
std::array< std::byte, N > & |
buffer, |
|
|
const Message & |
message |
|
) |
| -> std::expected<std::size_t, Error> |
|
noexcept |
implementation of Serialize.
First field presence and message-level validation. Then, the header is serialized. Then the payload is delegated to the Serdes policy for serialization. Finally, the integrity policy is executed and appended.
- Template Parameters
-
| Integrity | The integrity policy to use. |
| Serdes | The serialization policy to use. |
| Message | The message type to serialize. |
| N | The size of the buffer. |
- Parameters
-
| buffer | The buffer to serialize into. |
| message | The message to serialize. |
- Returns
- std::nullopt on success, or an Error if validation fails.
template<typename Integrity , typename Serdes , messages::CrunchMessage Message, std::size_t N>
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message>
| std::size_t Crunch::detail::SerializeWithoutValidation |
( |
std::array< std::byte, N > & |
buffer, |
|
|
const Message & |
message |
|
) |
| |
|
noexcept |
Serializes the message without any validation checks.
- Template Parameters
-
| Integrity | The integrity policy to use. |
| Serdes | The serialization policy to use. |
| Message | The message type to serialize. |
| N | The size of the buffer. |
- Parameters
-
| buffer | The buffer to serialize into. |
| message | The message to serialize. |
template<typename Message >
requires messages::CrunchMessage<Message>
| constexpr auto Crunch::detail::Validate |
( |
const Message & |
message | ) |
-> std::optional<Error> |
|
constexprnoexcept |
Forward declaration of Validate to enable recursion in ValidateField.
Validates a message (fields presence, values, submessages, and message-level logic).
ValidateField calls Validate for submessages, and Validate calls ValidateField for all fields. This forward declaration resolves the circular dependency.
- Template Parameters
-
| Message | The message type to validate. |
- Parameters
-
| message | The message to validate. |
- Returns
- std::nullopt on success, or an Error.
- Template Parameters
-
| Message | The message type to validate. |
- Parameters
-
| message | The message to validate. |
- Returns
- std::optional<Error> std::nullopt on success, or an Error.