66#ifndef OCVSMD_COMMON_DSDL_HELPERS_HPP_INCLUDED
77#define OCVSMD_COMMON_DSDL_HELPERS_HPP_INCLUDED
88
9+ #include < cetl/cetl.hpp>
910#include < cetl/pf20/cetlpf.hpp>
1011
1112#include < array>
@@ -21,13 +22,13 @@ namespace common
2122{
2223
2324template <typename Message>
24- static auto tryDeserializePayload (const cetl::span<const std::uint8_t > payload, Message& out_message)
25+ CETL_NODISCARD static auto tryDeserializePayload (const cetl::span<const std::uint8_t > payload, Message& out_message)
2526{
2627 return deserialize (out_message, {payload.data (), payload.size ()});
2728}
2829
2930template <typename Message, typename Action>
30- static int tryPerformOnSerialized (const Message& message, Action&& action)
31+ CETL_NODISCARD static int tryPerformOnSerialized (const Message& message, Action&& action)
3132{
3233 // Try to serialize the message to raw payload buffer.
3334 //
@@ -45,8 +46,9 @@ static int tryPerformOnSerialized(const Message& message, Action&& action)
4546 return std::forward<Action>(action)(bytes);
4647}
4748
48- template <typename Message, typename Result, std::size_t BufferSize, bool IsOnStack, typename Action>
49- static auto tryPerformOnSerialized (const Message& message, Action&& action) -> std::enable_if_t<IsOnStack, Result>
49+ template <typename Message, std::size_t BufferSize, bool IsOnStack, typename Action>
50+ CETL_NODISCARD static auto tryPerformOnSerialized (const Message& message,
51+ Action&& action) -> std::enable_if_t<IsOnStack, int>
5052{
5153 // Try to serialize the message to raw payload buffer.
5254 //
@@ -57,15 +59,16 @@ static auto tryPerformOnSerialized(const Message& message, Action&& action) -> s
5759 const auto result_size = serialize (message, {buffer.data (), buffer.size ()});
5860 if (!result_size)
5961 {
60- return Result{result_size. error ()} ;
62+ return EINVAL ;
6163 }
6264
6365 const cetl::span<const std::uint8_t > bytes{buffer.data (), result_size.value ()};
6466 return std::forward<Action>(action)(bytes);
6567}
6668
67- template <typename Message, typename Result, std::size_t BufferSize, bool IsOnStack, typename Action>
68- static auto tryPerformOnSerialized (const Message& message, Action&& action) -> std::enable_if_t<!IsOnStack, Result>
69+ template <typename Message, std::size_t BufferSize, bool IsOnStack, typename Action>
70+ CETL_NODISCARD static auto tryPerformOnSerialized (const Message& message,
71+ Action&& action) -> std::enable_if_t<!IsOnStack, int>
6972{
7073 // Try to serialize the message to raw payload buffer.
7174 //
@@ -75,7 +78,7 @@ static auto tryPerformOnSerialized(const Message& message, Action&& action) -> s
7578 const auto result_size = serialize (message, {buffer->data (), buffer->size ()});
7679 if (!result_size)
7780 {
78- return Result{result_size. error ()} ;
81+ return EINVAL ;
7982 }
8083
8184 const cetl::span<const std::uint8_t > bytes{buffer->data (), result_size.value ()};
0 commit comments