|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Messages with a four byte big-endian length before each payload. More...
#include <Framing.hpp>
Public Member Functions | |
| bool | broken () const noexcept |
| True after a terminal fault, until reset(). | |
| size_t | buffered () const noexcept |
| Partial header bytes plus payload bytes held for a frame that has not completed. | |
| LengthPrefixFramer (size_t max_payload=default_max_frame, bool reject_empty=false) noexcept | |
| template<MessageSink Sink> | |
| FrameReport | push (Message bytes, Sink &&sink) |
| void | reset () noexcept |
| Drop partial input and clear a terminal fault. | |
Private Member Functions | |
| FrameReport | fail (FrameReport &report, FrameFault fault) noexcept |
Private Attributes | |
| size_t | m_expected { 0 } |
| FrameFault | m_fault { FrameFault::None } |
| std::array< uint8_t, header_size > | m_header {} |
| size_t | m_header_size { 0 } |
| bool | m_in_payload { false } |
| size_t | m_max_payload |
| std::vector< uint8_t > | m_payload |
| bool | m_reject_empty |
Static Private Attributes | |
| static constexpr size_t | header_size = 4 |
Messages with a four byte big-endian length before each payload.
A zero length is an empty message, unless reject_empty is set and it becomes a fault. A length above max_payload is a fault. Faults are terminal: the stream cannot be resynchronised, so the framer delivers nothing more and reports the fault on every push until reset(). Messages completed earlier in the same push are still delivered. Nothing is reserved from the declared length, so a hostile length costs memory only as bytes actually arrive.
A frame that sits whole inside one push is delivered as a view into the input with no copy.
Not thread safe: one thread at a time per framer.
Definition at line 203 of file Framing.hpp.