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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! # abx — Android Binary XML parser
//!
//! Parses the ABX (Android Binary XML) format produced by `BinaryXmlSerializer`
//! and read back by `BinaryXmlPullParser` in AOSP.
//!
//! Not to be confused with **AXML**, the unrelated chunk-based binary format
//! used for compiled resources inside APKs (`AndroidManifest.xml`,
//! `res/**/*.xml`) — this crate does not read that format. See the crate
//! README's "Not AXML" section for the comparison.
//!
//! ## Two parsers, one format
//!
//! | Parser | Input | When to use |
//! |---|---|---|
//! | [`AbxParser`] | `&[u8]` | Data already in memory |
//! | [`AbxStreamParser`] | `impl Read` | Files, sockets, pipes — any reader |
//!
//! ## Format overview
//!
//! Every file starts with the 4-byte magic `ABX\0` (`0x41 0x42 0x58 0x00`).
//! After the magic each token is a single byte split into two nibbles:
//!
//! ```text
//! high nibble (0xF0) → data-type (TYPE_STRING, TYPE_INT, …)
//! low nibble (0x0F) → event kind (START_TAG, ATTRIBUTE, …)
//! ```
//!
//! Interned strings are prefixed with a `u16` index; the sentinel value
//! `0xFFFF` means "new string follows as a length-prefixed UTF-8 blob".
//!
//! ## Quick start
//!
//! ```rust,ignore
//! // Slice-based
//! use abx::AbxParser;
//! let data = std::fs::read("foo.abx")?;
//! let mut p = AbxParser::new(&data)?;
//! while let Some(ev) = p.next_event()? { println!("{ev:?}"); }
//!
//! // Stream-based (no intermediate Vec)
//! use abx::AbxStreamParser;
//! let file = std::fs::File::open("foo.abx")?;
//! let mut p = AbxStreamParser::new(std::io::BufReader::new(file))?;
//! while let Some(ev) = p.next_event()? { println!("{ev:?}"); }
//!
//! // Convenience helper
//! let mut p = abx::open_file("foo.abx")?;
//! let xml = p.to_xml()?;
//! ```
//!
//! ## Crate layout
//!
//! `error`, `wire`, `event`, `decode` (in-memory + streaming parsers, see
//! [`stream`]), and `de` (serde support, behind the `serialize` feature)
//! are internal modules — everything is re-exported at the crate root, so
//! `abx::Event` etc. work regardless of which file it's defined in.
pub use ;
pub use MAGIC;
pub use ;
pub use render_event;
pub use ;
pub use stream;
pub use AbxStreamParser;
pub use ;
pub use xml_to_abx;
pub use ;
pub use ;
// ---------------------------------------------------------------------------
// Convenience top-level functions
// ---------------------------------------------------------------------------
/// Convert ABX bytes to an XML string.
/// Parse ABX bytes and return all events.
/// Open a file and return a buffered [`AbxStreamParser`] over it.