Expand description
§librustty
librustty is the experimental public Rustty library. The Rust import name is
rustty.
Milestone 0 contains only a pure-Rust, incremental VT stream parser. It dispatches printable characters, controls, ESC/CSI sequences, and bounded OSC, DCS, APC, PM, and SOS strings. It does not implement a terminal grid, cursor, styles, PTYs, rendering, or desktop integration.
use rustty::{Handler, Parser};
#[derive(Default)]
struct Collector {
text: String,
}
impl Handler for Collector {
fn print(&mut self, ch: char) {
self.text.push(ch);
}
fn execute(&mut self, byte: u8) {
if byte == b'\n' {
self.text.push('\n');
}
}
}
let mut parser = Parser::new();
let mut collector = Collector::default();
parser.advance(&mut collector, b"hel");
parser.advance(&mut collector, b"lo\n");
parser.finish(&mut collector);
assert_eq!(collector.text, "hello\n");advance can be called with any chunk size, including one byte at a time. The
parser owns its mutable state and can be moved to another thread, but parsing
requires exclusive mutable access. Handler event views are borrowed only for
the duration of the callback and must be copied if they need to outlive it.
DCS events separate their parameter/intermediate prefix, final byte, and
bounded passthrough payload; APC, PM, and SOS expose their bounded payload
without interpreting it.
The parser replaces malformed or incomplete UTF-8 with U+FFFD. C0 and raw C1
control bytes are dispatched as controls. Control-string payloads are retained
only up to ParserOptions::max_string_bytes; excess bytes are discarded and
the final event is marked truncated. CSI parameters preserve semicolon and
colon structure, including empty values.
The API is experimental and may change in any 0.0.x release.
The public Rustty API.
Re-exports§
pub use vt::CsiDispatch;pub use vt::EscDispatch;pub use vt::Handler;pub use vt::OscDispatch;pub use vt::Param;pub use vt::Params;pub use vt::Parser;pub use vt::ParserOptions;pub use vt::StringDispatch;pub use vt::StringKind;pub use vt::StringTermination;pub use vt::Subparam;
Modules§
- vt
- Incremental VT stream parsing.