1//! # `object`
2//!
3//! The `object` crate provides a unified interface to working with object files
4//! across platforms. It supports reading relocatable object files and executable files,
5//! and writing relocatable object files and some executable files.
6//!
7//! ## Raw struct definitions
8//!
9//! Raw structs are defined for: [ELF](elf), [Mach-O](macho), [PE/COFF](pe),
10//! [XCOFF](xcoff), [archive].
11//! Types and traits for zerocopy support are defined in the [`pod`] and [`endian`] modules.
12//!
13//! ## Unified read API
14//!
15//! The [`read`] module provides a unified read API using the [`read::Object`] trait.
16//! There is an implementation of this trait for [`read::File`], which allows reading any
17//! file format, as well as implementations for each file format.
18//!
19//! ## Low level read API
20//!
21//! The [`read#modules`] submodules define helpers that operate on the raw structs.
22//! These can be used instead of the unified API, or in conjunction with it to access
23//! details that are not available via the unified API.
24//!
25//! ## Unified write API
26//!
27//! The [`mod@write`] module provides a unified write API for relocatable object files
28//! using [`write::Object`]. This does not support writing executable files.
29//!
30//! ## Low level write API
31//!
32//! The [`mod@write#modules`] submodules define helpers for writing the raw structs.
33//!
34//! ## Shared definitions
35//!
36//! The crate provides a number of definitions that are used by both the read and write
37//! APIs. These are defined at the top level module, but none of these are the main entry
38//! points of the crate.
39
40#![deny(missing_docs)]
41#![deny(missing_debug_implementations)]
42#![no_std]
43#![warn(rust_2018_idioms)]
44// Style.
45#![allow(clippy::collapsible_if)]
46#![allow(clippy::comparison_chain)]
47#![allow(clippy::manual_flatten)]
48#![allow(clippy::match_like_matches_macro)]
49#![allow(clippy::single_match)]
50#![allow(clippy::type_complexity)]
51// Occurs due to fallible iteration.
52#![allow(clippy::should_implement_trait)]
53// Unit errors are converted to other types by callers.
54#![allow(clippy::result_unit_err)]
55// Worse readability sometimes.
56#![allow(clippy::collapsible_else_if)]
57
58#[cfg(feature = "cargo-all")]
59compile_error!("'--all-features' is not supported; use '--features all' instead");
60
61#[cfg(any(feature = "read_core", feature = "write_core"))]
62#[allow(unused_imports)]
63#[macro_use]
64extern crate alloc;
65
66#[cfg(feature = "std")]
67#[allow(unused_imports)]
68#[macro_use]
69extern crate std;
70
71mod common;
72pub use common::*;
73
74#[macro_use]
75pub mod endian;
76pub use endian::*;
77
78#[macro_use]
79pub mod pod;
80pub use pod::*;
81
82#[cfg(feature = "read_core")]
83pub mod read;
84#[cfg(feature = "read_core")]
85pub use read::*;
86
87#[cfg(feature = "write_core")]
88pub mod write;
89
90#[cfg(feature = "archive")]
91pub mod archive;
92#[cfg(feature = "elf")]
93pub mod elf;
94#[cfg(feature = "macho")]
95pub mod macho;
96#[cfg(any(feature = "coff", feature = "pe"))]
97pub mod pe;
98#[cfg(feature = "xcoff")]
99pub mod xcoff;
100