pedant_core/resolution/rust/
target.rs1use std::sync::Arc;
5
6use super::edition::CargoEdition;
7use super::identity::{PackageId, TargetId};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub enum CargoTargetKind {
12 Library,
14 Binary,
16 Example,
18 Test,
20 Benchmark,
22 BuildScript,
24}
25
26impl CargoTargetKind {
27 pub(super) fn token(self) -> &'static str {
29 match self {
30 Self::Library => "lib",
31 Self::Binary => "bin",
32 Self::Example => "example",
33 Self::Test => "test",
34 Self::Benchmark => "bench",
35 Self::BuildScript => "build-script",
36 }
37 }
38}
39
40#[derive(Debug)]
42pub struct RustTarget {
43 pub(super) id: TargetId,
44 pub(super) package: PackageId,
45 pub(super) name: Arc<str>,
46 pub(super) kind: CargoTargetKind,
47 pub(super) entry_path: Arc<str>,
48 pub(super) edition: CargoEdition,
49}
50
51impl RustTarget {
52 pub fn id(&self) -> TargetId {
54 self.id
55 }
56
57 pub fn package(&self) -> PackageId {
59 self.package
60 }
61
62 pub fn name(&self) -> &str {
64 &self.name
65 }
66
67 pub fn kind(&self) -> CargoTargetKind {
69 self.kind
70 }
71
72 pub fn entry_path(&self) -> &str {
74 &self.entry_path
75 }
76
77 pub fn edition(&self) -> CargoEdition {
79 self.edition
80 }
81}