Skip to content

Conversation

RuthgerD
Copy link
Collaborator

so that it can be called with malformed data and not bring down the process

namespace {

[[nodiscard]] ClientRequest readClientRequest(std::span<const std::byte>& buf) noexcept {
[[nodiscard]] constexpr io::expected<std::optional<ClientRequest>>
Copy link
Member

@AeroStun AeroStun May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of nesting things, can we only use the expected and put std::errc::invalid_argument if the input is garbage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is that if the optional is empty then we need more bytes, if there is an unexpected value then the input is garbage. We can make a new error code that says like "give me more bytes" or something to flatten it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants