noline

Crates.ionoline
lib.rsnoline
version0.5.1
sourcesrc
created_at2022-03-14 14:49:28.873046
updated_at2024-12-12 14:33:22.279068
descriptionA no_std line editor
homepage
repositoryhttps://github.com/rustne-kretser/noline
max_upload_size
id549873
size140,843
Eivind Alexander Bergem (eivindbergem)

documentation

README

Pipeline Crates.io API reference

noline

Noline is an IO-agnostic #[no_std] line editor providing robust line editing for any system. The core functionality is IO-free, so it can be adapted to any system be it embedded, async, async embedded, WASM or IPoAC (IP over Avian Carriers).

Features:

  • IO-free
  • Minimal dependencies
  • No allocation needed - Both heap-based and static buffers are provided
  • UTF-8 support
  • Emacs keybindings
  • Line history

Possible future features:

  • Auto-completion and hints

The API should be considered experimental and will change in the future.

The core implementation consists of a state machine taking bytes as input and yielding iterators over byte slices. Because this is done without any IO, Noline can be adapted to work on any platform.

Noline comes with multiple implemenations:

  • [sync_editor::Editor] – Editor for synchronous IO
  • [async_editor::Editor] - Editor for asynchronous IO

Editors can be built using [builder::EditorBuilder].

Example

let prompt = "> ";

let mut io = MyIO {}; // IO handler, see full examples for details
                      // how to implement it

let mut editor = EditorBuilder::new_unbounded()
    .with_unbounded_history()
    .build_sync(&mut io)
    .unwrap();

while let Ok(line) = editor.readline(prompt, &mut io) {
    writeln!(io, "Read: '{}'", line).unwrap();
}

For more details, see docs.

Usage

Add this to your Cargo.toml:

[dependencies]
noline = "0.5.1"

License

MPL-2.0

Commit count: 71

cargo fmt