bytecode/lib.rs
1//! This library provides the ability to read bytecode.
2//!
3//! # Usage
4//!
5//! ## Basic
6//!
7//! ```
8//! use bytecode::ByteCode;
9//!
10//! let mut bytes = ByteCode::new(&[0, 1, 2, 3, 4, 5, 6, 7]);
11//!
12//! bytes += 3;
13//!
14//! let _first = bytes[0];
15//! let _second = bytes[1];
16//!
17//! let _subslice = &bytes[2..5];
18//! ```
19//!
20//! ## Utility methods
21//!
22//! ```
23//! use bytecode::ByteCode;
24//!
25//! let mut bytes = ByteCode::new(&[0, 1, 2, 3, 4, 5, 6, 7]);
26//!
27//! match bytes.peek(3) {
28//! // omitted
29//! _ => {}
30//! }
31//!
32//! if bytes.starts_with("foo".as_bytes()) {
33//! // omitted
34//! }
35//!
36//! bytes.skip(2);
37//!
38//! let _subslice = bytes.take(4);
39//! ```
40//!
41//! ```
42//! use bytecode::ByteCode;
43//!
44//! let mut bytes = ByteCode::new(&[0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x66, 0x6f, 0x6f]);
45//!
46//! let _u8 = bytes.take_into_u8(); // u8::MAX
47//! let _u16 = bytes.take_into_u16(); // u16::MAX
48//! let _u32 = bytes.take_into_u32(); // u32::MAX
49//!
50//! let _string = bytes.take_into_string(3); // "foo".to_owned()
51//! ```
52
53mod core;
54mod util;
55
56pub use crate::core::ByteCode;