rm_lines/lib.rs
1//! Binary parser for v5 of the reMarkable .lines binary format
2//!
3//! While similar to (and inspired by) [`lines-are-rusty`][rusty-lines],
4//! this crate focuses *solely* on parsing the `.rm` files generated
5//! by a reMarkable tablet (eg an individual notebook page). Other functionality
6//! should be layered in higher-level crates.
7//!
8//! [rusty-lines]: https://github.com/ax3l/lines-are-rusty
9
10mod color;
11pub use color::Color;
12
13mod header;
14pub(crate) use header::Header;
15
16mod layer;
17pub use layer::Layer;
18
19mod line;
20pub use line::Line;
21
22mod page;
23pub use page::Page;
24
25mod point;
26pub use point::Point;
27
28mod tool;
29pub use tool::Tool;
30
31mod version;
32pub use version::Version;
33
34mod private {
35 pub trait Sealed: Sized {}
36 impl Sealed for crate::Color {}
37 impl Sealed for crate::Layer {}
38 impl Sealed for crate::Header {}
39 impl Sealed for crate::Line {}
40 impl Sealed for crate::Page {}
41 impl Sealed for crate::Point {}
42 impl Sealed for crate::Tool {}
43 impl Sealed for crate::Version {}
44}
45
46/// Attempts to parse the implementing type from a byte sequence
47///
48/// This trait is currently built on the [nom][nom] parser combinator library,
49/// and leaks details of this implementation. As such, it is [sealed][sealed-traits].
50///
51/// [nom]: https://docs.rs/nom/latest/nom/
52/// [sealed-traits]: https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed
53pub trait Parse<'i>: private::Sealed {
54 fn parse(input: &'i [u8]) -> nom::IResult<&'i [u8], Self>;
55}