#include "capture.hpp" namespace capture { Status book_reset(Book* book) { if (book == nullptr) { return Status::invalid; } for (Entry& entry : book->entries) { entry = Entry{}; } book->accepted = 0; return Status::ok; } Status book_capture(Book* book, std::uint32_t channel, std::int64_t sec, std::int64_t nsec, const std::vector& payload) { if (book == nullptr || channel >= channel_count) { return Status::invalid; } if (payload.size() > payload_limit) { return Status::capacity; } Stamp normalized; Status status = normalize(sec, nsec, &normalized); if (status != Status::ok) { return status; } if (book->accepted == capture_limit) { return Status::capacity; } Entry replacement; replacement.present = true; replacement.stamp = normalized; replacement.sequence = book->accepted + 1; replacement.payload = payload; book->entries[channel] = replacement; ++book->accepted; return Status::ok; } Status book_snapshot(const Book* book, std::uint32_t channel, Entry* out) { if (book == nullptr || out == nullptr || channel >= channel_count) { return Status::invalid; } const Entry& selected = book->entries[channel]; if (!selected.present) { return Status::missing; } *out = selected; return Status::ok; } Status book_clear(Book* book, std::uint32_t channel) { if (book == nullptr || channel >= channel_count) { return Status::invalid; } book->entries[channel] = Entry{}; return Status::ok; } }