cargo_e/e_types.rs
1/// Represents the kind of target that can be run by `cargo-e`.
2///
3/// This differentiates between Rust examples and binaries.
4#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
5pub enum TargetKind {
6 Example,
7 Binary,
8}
9
10/// Represents an example or binary that can be executed using `cargo-e`.
11///
12/// This struct holds metadata about a runnable target within a Rust project.
13///
14/// # Fields
15/// - `name`: The actual name of the target (e.g., `"hello_world"`).
16/// - `display_name`: A formatted name used for display purposes.
17/// - `manifest_path`: The path to the `Cargo.toml` file defining the target.
18/// - `kind`: Specifies whether the target is an example or a binary.
19/// - `extended`: Indicates whether the example is located in an extended directory.
20///
21/// # Example
22/// ```
23/// use cargo_e::{Example, TargetKind};
24///
25/// let example = Example {
26/// name: "demo".to_string(),
27/// display_name: "Demo Example".to_string(),
28/// manifest_path: "examples/demo/Cargo.toml".to_string(),
29/// kind: TargetKind::Example,
30/// extended: true,
31/// };
32///
33/// assert_eq!(example.name, "demo");
34/// assert!(example.extended);
35/// ```
36#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
37pub struct Example {
38 pub name: String,
39 pub display_name: String,
40 pub manifest_path: String,
41 pub kind: TargetKind,
42 pub extended: bool,
43}