astd/
meta.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//! The [`meta`] module provides details about the binary being compiled.
//!
//! [`meta`]: crate::meta

/// The full version of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_version {
  () => {
    env!("CARGO_PKG_VERSION")
  };
}

/// The major version of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_version_major {
  () => {
    env!("CARGO_PKG_VERSION_MAJOR")
  };
}

/// The minor version of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_version_minor {
  () => {
    env!("CARGO_PKG_VERSION_MINOR")
  };
}

/// The patch version of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_version_patch {
  () => {
    env!("CARGO_PKG_VERSION_PATCH")
  };
}

/// The pre-release version of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_version_pre {
  () => {
    env!("CARGO_PKG_VERSION_PRE")
  };
}

/// Colon separated list of authors from the manifest of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_authors {
  () => {
    env!("CARGO_PKG_AUTHORS")
  };
}

/// The name of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_name {
  () => {
    env!("CARGO_PKG_NAME")
  };
}

/// The description from the manifest of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_description {
  () => {
    env!("CARGO_PKG_DESCRIPTION")
  };
}

/// The home page from the manifest of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_homepage {
  () => {
    env!("CARGO_PKG_HOMEPAGE")
  };
}

/// The repository from the manifest of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_repository {
  () => {
    env!("CARGO_PKG_REPOSITORY")
  };
}

/// The license from the manifest of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_license {
  () => {
    env!("CARGO_PKG_LICENSE")
  };
}

/// The license file from the manifest of your package.
#[macro_export]
#[doc(hidden)]
macro_rules! cargo_pkg_license_file {
  () => {
    env!("CARGO_PKG_LICENSE_FILE")
  };
}

#[doc(inline)]
pub use cargo_pkg_version;

#[doc(inline)]
pub use cargo_pkg_version_major;

#[doc(inline)]
pub use cargo_pkg_version_minor;

#[doc(inline)]
pub use cargo_pkg_version_patch;

#[doc(inline)]
pub use cargo_pkg_version_pre;

#[doc(inline)]
pub use cargo_pkg_authors;

#[doc(inline)]
pub use cargo_pkg_name;

#[doc(inline)]
pub use cargo_pkg_description;

#[doc(inline)]
pub use cargo_pkg_homepage;

#[doc(inline)]
pub use cargo_pkg_repository;

#[doc(inline)]
pub use cargo_pkg_license;

#[doc(inline)]
pub use cargo_pkg_license_file;

/// Representation of a semantic-version in `(major, minor, patch)` notation.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Version {
  /// The major version component
  pub major: u16,
  /// The minor version component
  pub minor: u16,
  /// The patch version component
  pub patch: u16,
}

impl std::fmt::Display for Version {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
  }
}

impl std::fmt::Debug for Version {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    <Self as std::fmt::Display>::fmt(self, f)
  }
}

/// Gets the current crate's version information from the meta cargo manifest.
#[macro_export]
#[doc(hidden)]
macro_rules! crate_version {
  () => {
    $crate::meta::Version {
      major: $crate::u16::from_str_radix10($crate::meta::cargo_pkg_version_major!()),
      minor: $crate::u16::from_str_radix10($crate::meta::cargo_pkg_version_minor!()),
      patch: $crate::u16::from_str_radix10($crate::meta::cargo_pkg_version_patch!()),
    }
  };
}

#[doc(inline)]
pub use crate_version;