1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! 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
//! ```no_run
//! # use noline::{builder::EditorBuilder};
//! # use embedded_io::{Read, Write, ErrorType};
//! # use core::convert::Infallible;
//! # struct MyIO {}
//! # impl ErrorType for MyIO {
//! # type Error = Infallible;
//! # }
//! # impl embedded_io::Write for MyIO {
//! # fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { unimplemented!() }
//! # fn flush(&mut self) -> Result<(), Self::Error> { unimplemented!() }
//! # }
//! # impl embedded_io::Read for MyIO {
//! # fn read(&mut self, buf: &mut[u8]) -> Result<usize, Self::Error> { unimplemented!() }
//! # }
//! # let mut io = MyIO {};
//! 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();
//! }
//! ```
pub
pub