Skip to main content

Module counting_writer

Module counting_writer 

Source
Expand description

Counting writer for tracking bytes emitted.

This module provides a wrapper around any Write implementation that counts the number of bytes written. This is used to verify O(changes) output size for diff-based rendering.

§Usage

use ftui_render::counting_writer::CountingWriter;
use std::io::Write;

let mut buffer = Vec::new();
let mut writer = CountingWriter::new(&mut buffer);

writer.write_all(b"Hello, world!").unwrap();
assert_eq!(writer.bytes_written(), 13);

writer.reset_counter();
writer.write_all(b"Hi").unwrap();
assert_eq!(writer.bytes_written(), 2);

Structs§

CountingWriter
A write wrapper that counts bytes written.
PresentStats
Statistics from a present() operation.
StatsCollector
A stats collector for measuring present operations.

Constants§

BYTES_PER_CELL_MAX
Expected bytes per cell change (approximate worst case).
BYTES_PER_CURSOR_MOVE
Bytes for cursor move sequence (CUP).
SYNC_OVERHEAD
Bytes for sync output wrapper.

Functions§

expected_max_bytes
Calculate expected maximum bytes for a frame with given changes.