|
| struct | Around |
| | Validates that a floating-point value is within a tolerance of a target. More...
|
| |
| struct | Buffer |
| | A lightweight wrapper around a std::array for serializing/deserializing messages. More...
|
| |
| struct | EqualTo |
| | Validates that a value equals a compile-time threshold. More...
|
| |
| struct | Error |
| | Represents an error occurred during Crunch operations. More...
|
| |
| struct | Even |
| | Validates that an integral value is even. More...
|
| |
| struct | False |
| | Validates that a boolean value is false. More...
|
| |
| struct | FixedString |
| |
| struct | GreaterThan |
| | Validates that a value is greater than a compile-time threshold. More...
|
| |
| struct | GreaterThanOrEqualTo |
| | Validates that a value is greater than or equal to a compile-time threshold. More...
|
| |
| struct | IsFinite |
| | Validates that a floating-point value is finite (not NaN or Inf). More...
|
| |
| struct | Length |
| | Validates that a string-like or container value has a specific length. More...
|
| |
| struct | LengthAtLeast |
| | Validates that a container has at least N elements. More...
|
| |
| struct | LengthAtMost |
| | Validates that a container has at most N elements. More...
|
| |
| struct | LessThan |
| | Validates that a value is less than a compile-time threshold. More...
|
| |
| struct | LessThanOrEqualTo |
| | Validates that a value is less than or equal to a compile-time threshold. More...
|
| |
| struct | Negative |
| | Validates that a value is strictly negative (< 0). More...
|
| |
| struct | None |
| | Validates nothing (always succeeds). More...
|
| |
| struct | NotEqualTo |
| | Validates that a value does not equal a compile-time threshold. More...
|
| |
| struct | NotZero |
| | Validates that a value is not zero. More...
|
| |
| struct | NullTerminated |
| | Validates that a string does not contain embedded nulls. More...
|
| |
| struct | Odd |
| | Validates that an integral value is odd. More...
|
| |
| struct | OneOf |
| | Validates that a value is one of a set of compile-time values. More...
|
| |
| struct | Optional |
| | Presence validator allowing an optional field (can be unset). More...
|
| |
| struct | Positive |
| | Validates that a value is non-negative (>= 0). More...
|
| |
| struct | Required |
| | Presence validator enforcing that a field MUST be set. More...
|
| |
| struct | StringEquals |
| | Validates that a string equals a compile-time string. More...
|
| |
| struct | StringNotEquals |
| | Validates that a string does not equal a compile-time string. More...
|
| |
| struct | True |
| | Validates that a boolean value is true. More...
|
| |
| struct | Unique |
| | Validates that a container has unique elements. More...
|
| |
|
template<typename T >
requires std::integral<T> || std::is_enum_v<T> || std::floating_point<T> |
| constexpr T | LittleEndian (T value) noexcept |
| | Converts a value to/from Little Endian byte order.
|
| |
template<messages::CrunchMessage Message, typename Integrity , typename Serdes >
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message> |
| constexpr auto | GetBuffer () noexcept |
| | Creates a correctly sized Buffer for the given configuration.
|
| |
| template<messages::CrunchMessage Message> |
| constexpr auto | Validate (const Message &message) noexcept -> std::optional< Error > |
| | Validates a message (field presence + message-level validation).
|
| |
template<typename BufferType , typename Message >
requires IsBuffer<BufferType> && messages::CrunchMessage<Message> && std::same_as<typename BufferType::MessageType, Message> |
| constexpr auto | Serialize (BufferType &buffer, const Message &message) noexcept -> std::optional< Error > |
| | Serializes a message into the provided buffer.
|
| |
template<typename BufferType , typename Message >
requires IsBuffer<BufferType> && messages::CrunchMessage<Message> && std::same_as<typename BufferType::MessageType, Message> |
| constexpr void | SerializeWithoutValidation (BufferType &buffer, const Message &message) noexcept |
| | Serializes a message into the provided buffer without validation.
|
| |
template<typename BufferType , typename Message >
requires IsBuffer<BufferType> && messages::CrunchMessage<Message> && std::same_as<typename BufferType::MessageType, Message> |
| constexpr auto | Deserialize (const BufferType &buffer, Message &out_message) -> std::optional< Error > |
| | Deserializes a message from a buffer.
|
| |
The public API for Crunch.
This section contains all the interfaces for serializing and deserializing messages, and transitively provides the necessary types for defining messages and fields.
Top-level APIs
- GetBuffer: Creates a strongly-typed buffer of the maximum serialized message size for a given Message, Integrity, and Serdes combination.
- Validate: Validates field presence and message-level constraints.
- Serialize: Validates and writes a message into a buffer, appending integrity checks.
- Deserialize: Verifies integrity and reads a message from a buffer.
template<typename BufferType , typename Message >
requires IsBuffer<BufferType> && messages::CrunchMessage<Message> && std::same_as<typename BufferType::MessageType, Message>
| constexpr auto Crunch::Deserialize |
( |
const BufferType & |
buffer, |
|
|
Message & |
out_message |
|
) |
| -> std::optional<Error> |
|
constexpr |
Deserializes a message from a buffer.
Verifies the integrity of the buffer, then attempts to deserialize the content into a Message object.
Constraints:
- BufferType must be an instantiation of Crunch::Buffer.
- Message must satisfy the CrunchMessage concept.
- BufferType::MessageType must be the same as Message.
- Template Parameters
-
| BufferType | The Buffer type |
| Message | The CrunchMessage type to deserialize into. |
- Parameters
-
| buffer | The source Buffer to read from. |
| out_message | Output parameter for the deserialized message. |
- Returns
- std::optional<Error> std::nullopt on success, or an Error (Integrity/Deserialization).
template<messages::CrunchMessage Message, typename Integrity , typename Serdes >
requires IntegrityPolicy<Integrity> && SerdesPolicy<Serdes, Message>
| constexpr auto Crunch::GetBuffer |
( |
| ) |
|
|
constexprnoexcept |
Creates a correctly sized Buffer for the given configuration.
This function calculates the exact size required for the message serialization plus any integrity overhead at compile time.
- Template Parameters
-
| Message | The CrunchMessage type. |
| Integrity | The IntegrityPolicy (e.g., integrity::None, integrity::CRC16). |
| Serdes | The SerdesPolicy (e.g., serdes::PackedLayout). |
- Returns
- A Buffer object ready for use with Serialize/Deserialize.
template<typename BufferType , typename Message >
requires IsBuffer<BufferType> && messages::CrunchMessage<Message> && std::same_as<typename BufferType::MessageType, Message>
| constexpr auto Crunch::Serialize |
( |
BufferType & |
buffer, |
|
|
const Message & |
message |
|
) |
| -> std::optional<Error> |
|
constexprnoexcept |
Serializes a message into the provided buffer.
Validates the message content, serializes it according to the Serdes policy, and applies the Integrity policy (e.g., checksum).
Constraints:
- BufferType must be an instantiation of Crunch::Buffer.
- Message must satisfy the CrunchMessage concept.
- BufferType::MessageType must be the same as Message.
- Template Parameters
-
| BufferType | The Buffer type (deduced from buffer parameter). |
| Message | The CrunchMessage type to serialize. |
- Parameters
-
| buffer | The destination Buffer (must match Message type). |
| message | The message to serialize. |
- Returns
- std::optional<Error> std::nullopt on success, or an Error if validation fails.
template<typename BufferType , typename Message >
requires IsBuffer<BufferType> && messages::CrunchMessage<Message> && std::same_as<typename BufferType::MessageType, Message>
| constexpr void Crunch::SerializeWithoutValidation |
( |
BufferType & |
buffer, |
|
|
const Message & |
message |
|
) |
| |
|
constexprnoexcept |
Serializes a message into the provided buffer without validation.
Does strictly serialization logic (header, payload, checksum) without running any validation checks. Useful for forwarding invalid messages, testing, or performance-critical paths where validation is done elsewhere.
- Template Parameters
-
| BufferType | The Buffer type |
| Message | The CrunchMessage type to serialize. |
- Parameters
-
| buffer | The destination Buffer (must match Message type). |
| message | The message to serialize. |