1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! General configuration methods for `WireframeApp`.
use super::WireframeApp;
use crate::{
app::{
MemoryBudgets,
Packet,
builder_defaults::{MAX_READ_TIMEOUT_MS, MIN_READ_TIMEOUT_MS, default_fragmentation},
},
codec::FrameCodec,
fragment::FragmentationConfig,
serializer::Serializer,
};
impl<S, C, E, F> WireframeApp<S, C, E, F>
where
S: Serializer + Send + Sync,
C: Send + 'static,
E: Packet,
F: FrameCodec,
{
/// Configure the inbound read wake-up interval in milliseconds.
///
/// Clamped between 1 and 86,400,000 milliseconds (24 h). When the interval
/// elapses without a frame, the connection purges expired partial messages
/// and keeps waiting: this does not close an idle connection.
#[must_use]
pub fn read_timeout_ms(mut self, timeout_ms: u64) -> Self {
self.read_timeout_ms = timeout_ms.clamp(MIN_READ_TIMEOUT_MS, MAX_READ_TIMEOUT_MS);
self
}
/// Override the fragmentation configuration.
///
/// Provide `None` to disable fragmentation entirely.
#[must_use]
pub const fn fragmentation(mut self, config: Option<FragmentationConfig>) -> Self {
self.fragmentation = config;
self
}
/// Configure per-connection memory budgets for inbound buffering.
///
/// These budgets apply across the inbound assembly pipeline. Message
/// assembly uses them for per-frame rejection, and retained fragment and
/// assembly bytes together drive soft-pressure read pacing and hard-cap
/// connection aborts.
#[must_use]
pub const fn memory_budgets(mut self, budgets: MemoryBudgets) -> Self {
self.memory_budgets = Some(budgets);
self
}
/// Enable transport fragmentation using codec-derived defaults.
///
/// The derived settings are bounded by the current frame codec budget.
/// Call this after `with_codec` or `buffer_capacity` so defaults align with
/// the final frame length.
#[must_use]
pub fn enable_fragmentation(mut self) -> Self {
self.fragmentation = default_fragmentation(self.codec.max_frame_length());
self
}
}