pub struct InputQueueConfig {
pub queue_length: usize,
}Expand description
Configuration for input queue sizing.
These settings control the size of the input queue (circular buffer) that stores player inputs. A larger queue allows for longer input history and higher frame delays, but uses more memory.
§Forward Compatibility
New fields may be added to this struct in future versions. To ensure your
code continues to compile, always use the ..Default::default() or
..InputQueueConfig::default() pattern when constructing instances.
§Memory Usage
Each input queue stores queue_length inputs per player. With 2 players and
128-frame queue (default), this is 256 input slots total.
§Constraints
queue_lengthmust be at least 2 (minimum for circular buffer operation)queue_lengthshould be a power of 2 for optimal modulo performance (not enforced)frame_delaymust be less thanqueue_length(enforced at session creation)
§Example
use fortress_rollback::InputQueueConfig;
// Default configuration (128 frames = ~2.1 seconds at 60 FPS)
let default = InputQueueConfig::default();
assert_eq!(default.queue_length, 128);
// For games needing longer input history
let high_latency = InputQueueConfig::high_latency();
assert_eq!(high_latency.queue_length, 256);
// For memory-constrained environments
let minimal = InputQueueConfig::minimal();
assert_eq!(minimal.queue_length, 32);Fields§
§queue_length: usizeThe length of the input queue (circular buffer) per player.
This determines:
- How many frames of input history are stored
- The maximum allowed frame delay (
queue_length - 1) - Memory usage per player
At 60 FPS:
- 32 frames = ~0.5 seconds
- 64 frames = ~1.1 seconds
- 128 frames (default) = ~2.1 seconds
- 256 frames = ~4.3 seconds
§Formal Specification Alignment
- TLA+:
QUEUE_LENGTHinspecs/tla/InputQueue.tla(uses 3 for model checking) - Kani:
INPUT_QUEUE_LENGTHinsrc/input_queue.rs(uses 8 for tractable verification) - Z3:
INPUT_QUEUE_LENGTHintests/test_z3_verification.rs(uses 128) - formal-spec.md: INV-4 (queue length bounds), INV-5 (index validity)
- spec-divergences.md: Documents why different values are used
Default: 128
Implementations§
Source§impl InputQueueConfig
impl InputQueueConfig
Sourcepub fn high_latency() -> Self
pub fn high_latency() -> Self
Configuration for high-latency networks.
Uses a larger queue (256 frames = ~4.3 seconds at 60 FPS) to allow for higher frame delays and longer rollback windows.
Sourcepub fn minimal() -> Self
pub fn minimal() -> Self
Configuration for minimal memory usage.
Uses a smaller queue (32 frames = ~0.5 seconds at 60 FPS). Suitable for games with low latency requirements.
Sourcepub fn standard() -> Self
pub fn standard() -> Self
Configuration for standard networks.
Uses the default queue size (128 frames = ~2.1 seconds at 60 FPS).
Sourcepub fn max_frame_delay(&self) -> usize
pub fn max_frame_delay(&self) -> usize
Returns the maximum allowed frame delay for this configuration.
This is always queue_length - 1 to ensure the circular buffer
doesn’t overflow when advancing the queue head.
Sourcepub fn validate_frame_delay(
&self,
frame_delay: usize,
) -> Result<(), FortressError>
pub fn validate_frame_delay( &self, frame_delay: usize, ) -> Result<(), FortressError>
Validates that the given frame delay is valid for this configuration.
§Errors
Returns a FortressError if frame_delay >= queue_length.
Sourcepub fn validate(&self) -> Result<(), FortressError>
pub fn validate(&self) -> Result<(), FortressError>
Trait Implementations§
Source§impl Clone for InputQueueConfig
impl Clone for InputQueueConfig
Source§fn clone(&self) -> InputQueueConfig
fn clone(&self) -> InputQueueConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more