zarja_core/lib.rs
1//! # zarja-core
2//!
3//! A library for extracting and reconstructing Protocol Buffer definitions from compiled binaries.
4//!
5//! This crate provides the core functionality for:
6//! - Scanning binary files for embedded protobuf file descriptors
7//! - Parsing raw protobuf wire format data
8//! - Reconstructing human-readable `.proto` source files
9//!
10//! ## Architecture
11//!
12//! The library is organized into several modules:
13//!
14//! - [`scanner`]: Binary scanning and wire format parsing
15//! - [`proto`]: Proto definition reconstruction
16//! - [`error`]: Error types and handling
17//!
18//! ## Example
19//!
20//! ```no_run
21//! use zarja_core::{Scanner, ScanStrategy, ProtoReconstructor};
22//! use std::fs;
23//!
24//! // Read a binary file
25//! let data = fs::read("./target/release/my_app")?;
26//!
27//! // Scan for embedded descriptors
28//! let scanner = Scanner::new();
29//! let results = scanner.scan(&data)?;
30//!
31//! // Reconstruct proto definitions
32//! for result in results {
33//! if let Ok(reconstructor) = ProtoReconstructor::from_bytes(result.as_bytes()) {
34//! println!("{}", reconstructor.reconstruct());
35//! }
36//! }
37//! # Ok::<(), Box<dyn std::error::Error>>(())
38//! ```
39//!
40//! ## Extensibility
41//!
42//! The library provides several traits for customization:
43//!
44//! - [`ProtoWriter`]: Customize how proto elements are written
45//! - [`ScanStrategy`]: Customize the binary scanning algorithm
46//!
47
48#![deny(unsafe_code)]
49#![warn(missing_docs, rust_2018_idioms, unreachable_pub)]
50
51pub mod error;
52pub mod proto;
53pub mod scanner;
54
55// Re-export primary types for convenience
56pub use error::{Error, Result};
57pub use proto::{NullWriter, ProtoReconstructor, ProtoWriter, ReconstructorConfig, StatsWriter};
58pub use scanner::{ScanResult, ScanStrategy, Scanner, ScannerConfig};
59
60/// Crate version for programmatic access
61pub const VERSION: &str = env!("CARGO_PKG_VERSION");
62
63/// Maximum valid protobuf field number (2^29 - 1)
64/// Used for `reserved X to max` ranges
65pub const MAX_FIELD_NUMBER: u32 = 536_870_911;