Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
RnrFile.h File Reference

.rnrDonner Renderer Recording — is a compact on-disk container for a single sandbox wire stream plus enough metadata to reproduce the original render. The file body is the raw wire bytes from SandboxHost::renderToBackend (or SerializingRenderer::takeBuffer) appended verbatim — no re-encoding, no compression. More...

#include <cstdint>
#include <filesystem>
#include <span>
#include <string>
#include <vector>
Include dependency graph for RnrFile.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::sandbox::RnrHeader
 Per-file metadata. All fields are POD or trivially serializable. uri may be empty when the recording originated from an in-memory string. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::editor::sandbox::BackendHint : uint32_t {
  kUnspecified = 0 ,
  kTinySkia = 1 ,
  kGeode = 3
}
 Backend that recorded the stream, for diagnostic round-tripping. The replayer never acts on this — the host picks whatever backend it wants to replay into — but it's useful for bug reports ("this .rnr was captured with backend=tiny_skia").
enum class  donner::editor::sandbox::RnrIoStatus {
  kOk ,
  kWriteFailed ,
  kReadFailed ,
  kTruncated ,
  kMagicMismatch ,
  kVersionMismatch ,
  kUriTooLong
}
 Outcome of an I/O call. More...

Functions

RnrIoStatus donner::editor::sandbox::SaveRnrFile (const std::filesystem::path &path, const RnrHeader &header, std::span< const uint8_t > wireBytes)
 Writes header + wireBytes to the given path, creating or replacing the file. wireBytes is copied verbatim after the header — callers should pass the exact bytes returned by the sandbox or serializing renderer, including the kStreamHeader and kEndFrame messages.
RnrIoStatus donner::editor::sandbox::LoadRnrFile (const std::filesystem::path &path, RnrHeader &outHeader, std::vector< uint8_t > &outWireBytes)
 Reads a .rnr file into memory. On success, outHeader is populated and outWireBytes contains the raw wire stream suitable for ReplayingRenderer::pumpFrame.
RnrIoStatus donner::editor::sandbox::ParseRnrBuffer (std::span< const uint8_t > buffer, RnrHeader &outHeader, std::vector< uint8_t > &outWireBytes)
 Parses a recording from an in-memory buffer instead of disk. Same semantics as LoadRnrFile, but without any I/O — useful for unit tests and for round-tripping a recording through a memfd without hitting the filesystem.
std::vector< uint8_t > donner::editor::sandbox::EncodeRnrBuffer (const RnrHeader &header, std::span< const uint8_t > wireBytes)
 Serializes header + wireBytes into a contiguous byte vector without touching the filesystem. Always succeeds (just allocates and memcpys).

Variables

constexpr uint32_t donner::editor::sandbox::kRnrFileMagic = 0x464E5244u
 Magic identifier for an .rnr file (DRNF in ASCII, little-endian u32).
constexpr uint32_t donner::editor::sandbox::kRnrFileVersion = 1
 Bumped on any breaking change to the header layout. Does not need to match Wire.h's kWireVersion.
constexpr uint32_t donner::editor::sandbox::kRnrMaxUriBytes = 64u * 1024u
 Upper bound on a URI stored in a recording header. 64 KiB is plenty for any real path or URL, and cheap to validate on read.

Detailed Description

.rnrDonner Renderer Recording — is a compact on-disk container for a single sandbox wire stream plus enough metadata to reproduce the original render. The file body is the raw wire bytes from SandboxHost::renderToBackend (or SerializingRenderer::takeBuffer) appended verbatim — no re-encoding, no compression.

Layout:

u32 fileMagic = 'DRNF' (0x464E5244 little-endian)
u32 fileVersion = 1
u64 timestampNanos (unix epoch, best-effort)
u32 widthPixels
u32 heightPixels
u32 backendHint (see BackendHint enum)
u32 uriLength
u8[] uri (UTF-8, no terminator, may be empty)
u8[] wireStream (rest of file — kStreamHeader..kEndFrame)

The fileVersion is distinct from kWireVersion in Wire.h. A file format bump doesn't necessarily imply a wire protocol change, and vice versa — the file header wraps the wire stream, not the other way around.

Enumeration Type Documentation

◆ RnrIoStatus

Outcome of an I/O call.

Enumerator
kTruncated 

Stream ended inside the header.

kMagicMismatch 

First four bytes aren't DRNF.

kVersionMismatch 

Header version newer/older than we understand.

kUriTooLong 

uriLength exceeds kRnrMaxUriBytes.