edit-session 0.1.0-alpha.5

Toolkit-independent preview, validation and commit lifecycle
Documentation
  • Coverage
  • 100%
    20 out of 20 items documented0 out of 14 items with examples
  • Size
  • Source code size: 135.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 300.8 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • PerchAnton/edit-session
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PerchAnton

edit-session

A small, toolkit-independent Rust library for preview, validation and commit lifecycles. no_std, zero runtime dependencies, Rust 1.88+. MIT OR Apache-2.0.

Use it when several controls edit one draft and the host should commit one final change. The host owns validation, preview rendering, commands, undo and document identity. This crate does not provide widgets or an undo stack.

Installation

Add a published copy of this prerelease to your dependencies:

[dependencies]
edit-session = "=0.1.0-alpha.5"

This is an experimental alpha. Pin an exact version and keep Cargo.lock for applications. Read the compatibility policy before upgrading. For other distribution options and current publication status, see the project README.

Example

use edit_session::EditSession;

let context = ("document-7", "layer-2", 42_u64);
let live_opacity = 100_u8;
let mut draft = EditSession::new(live_opacity, context);
draft.propose::<&str>(Ok(75)).unwrap();
draft.propose::<&str>(Ok(50)).unwrap();

if let Some(change) = draft.finish(&live_opacity, &context).unwrap() {
    assert_eq!(change.after, 50);
    // Send change.after to the host's validated command once.
}

finish consumes the session. If the host command can reject a change and the UI must retain the draft for retry, use the borrowed-preview/check pattern in the tested recovery example. Check the live value and context again on every attempt.

The separate interaction-check runner is optional and is not a dependency of this crate.