Skip to main content

Module builder

Module builder 

Source
Expand description

Server-side frame construction discipline.

Every server-emitted frame today is built by stitching together Frame::new + Frame::with_stream + Frame::with_flags at the call site. That spreads four invariants across every dispatch path:

  1. Correlation-id propagation — each response must echo the request frame’s id (or 0 for unsolicited frames).
  2. MORE_FRAMES sequencing — only the last frame of a multi- frame reply may clear the flag.
  3. MAX_FRAME_SIZE enforcement — the codec checks on decode but a producer happily encodes oversized frames the peer will reject anyway.
  4. Compression policy — callers either opt in by setting Flags::COMPRESSED or do not, and the codec silently falls back to plaintext on incompressible input.

FrameBuilder owns those invariants. The acceptance test for this module is the deletion test: deleting builder.rs forces frame-construction discipline back to inline Frame::new calls at every dispatch site.

use reddb_wire::redwire::{FrameBuilder, MessageKind};

let frame = FrameBuilder::reply_to(request.correlation_id)
    .kind(MessageKind::Result)
    .payload(body)
    .stream_id(42)
    .more_frames(false)
    .build()?;

The builder is engine-free — it only depends on Frame, MessageKind, Flags, and the size constants from this crate. Server dispatch (auth, session, listener) constructs frames through the builder; the codec stays focused on bytes.

Structs§

FrameBuilder
Builder for server-emitted Frames.

Enums§

BuildError
Errors surfaced at build() time so they fail at construction rather than at encode time, where the call site has already lost the context to recover.