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