Message fragmentation

Updated Nov 29, 2025

WireframeApp now fragments oversized payloads automatically. The builder derives a FragmentationConfig from buffer_capacity: any payload that will not fit into a single frame is split into fragments carrying a FragmentHeader (message_id, fragment_index, is_last_fragment) wrapped with the FRAG marker. The connection reassembles fragments before invoking handlers, so handlers continue to work with complete Envelope values.[^6]

Fragmented messages enforce two guards: max_message_size caps the total reassembled payload, and reassembly_timeout evicts stale partial messages. Customize or disable fragmentation via the builder:

use std::{num::NonZeroUsize, time::Duration};
use wireframe::{
    app::WireframeApp,
    fragment::FragmentationConfig,
};

// Assume `handler` is defined elsewhere; any Handler compatible with WireframeApp works.
let cfg = FragmentationConfig::for_frame_budget(
    1024,
    NonZeroUsize::new(16 * 1024).unwrap(),
    Duration::from_secs(30),
).expect("frame budget too small for fragments");

let app = WireframeApp::new()?
    .fragmentation(Some(cfg))
    .route(42, handler)?;

Set fragmentation(None) when the transport already supports large frames, or when fragmentation should be deferred to an upstream gateway. The ConnectionActor mirrors the same behaviour for push traffic and streaming responses through enable_fragmentation, ensuring client-visible frames follow the same format.