ratresume 0.1.0

A Rust library for reporting program-resume commands with OSC 7577
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented1 out of 1 items with examples
  • Size
  • Source code size: 71.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 167.2 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • orhun

ratresume 🐀

Crates.io Documentation GitHub release License: MIT Ratatui

A Rust library for reporting program-resume commands with Program Resume Protocol (OSC 7577).

flowchart LR
    App[Your TUI] -->|report command| Terminal[Terminal]
    Terminal -->|restart app| App

Q: What is this for?
A: ratresume allows your app to tell a supporting terminal how to restart your app with the same arguments and working directory after a terminal session is restored.

Quick start

Add ratresume to your project:

cargo add ratresume

Call Reporter::from_env to read OSC7577_TOKEN.
Supporting terminals set this variable; if it is missing, no report will be sent.

let mut reporter = ratresume::Reporter::from_env()?;

Describe how your app restores its saved state:

let session_path = std::path::Path::new("/tmp/session.json");
let argv = vec![
    "my-tui".to_owned(),
    "--resume".to_owned(),
    session_path.to_string_lossy().into_owned(),
];
let cwd = std::env::current_dir()?;

Call Reporter::report to send the resume command to the terminal:

if let Some(reporter) = reporter.as_mut() {
    reporter.report(&argv, Some(&cwd))?;
}

A supporting terminal can use this command to restart your app with the same arguments and working directory when restoring the session.

Usage

Here is a simple function that reports how to resume the current application with --resume <session_path>:

fn report_resume_command(
    session_path: &std::path::Path,
) -> Result<(), ratresume::Error> {
    let Some(mut reporter) = ratresume::Reporter::from_env()? else {
        return Ok(());
    };

    let executable = std::env::current_exe()?;
    let cwd = std::env::current_dir()?;
    let session_path = session_path.to_string_lossy().into_owned();
    let argv = vec![
        executable.to_string_lossy().into_owned(),
        "--resume".to_owned(),
        session_path,
    ];

    reporter.report(&argv, Some(&cwd))?;

    Ok(())
}

Examples

  • ratatui.rs is a small counter app that saves its value and reports how to resume itself.

    Run it with:

    cargo run --example ratatui
    

    Use the arrow keys to change the counter and q to quit.

Contributing

See CONTRIBUTING.md for development checks and contribution guidelines.

Please report security issues through GitHub Security Advisories, not public issues. See SECURITY.md for details.

License

Licensed under The MIT License.

🦀 ノ( º _ º ノ) - respect crables!

Copyright

Copyright © 2026, Orhun Parmaksız