gsym/version.rs
1/// GSYM encoding version.
2///
3/// [`V1`](Self::V1) is the default and the version current tooling reads.
4/// [`V2`](Self::V2) raises v1's 4 GiB size limit and its 20-byte build-ID
5/// limit, at the cost of requiring LLVM 23 or newer to read it.
6///
7/// Select a version with
8/// [`GsymBuilder::version`](crate::GsymBuilder::version), or convert an existing
9/// file with [`Gsym::transcode`](crate::Gsym::transcode). Writing never upgrades
10/// a file on its own: a model that exceeds a v1 limit fails with
11/// [`Error::V1LimitExceeded`](crate::Error::V1LimitExceeded).
12///
13/// See [`docs::format`](crate::docs::format) for what differs on disk.
14#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
15#[non_exhaustive]
16pub enum GsymVersion {
17 /// Widely deployed format, readable by every current tool.
18 #[default]
19 V1,
20 /// Format without v1's size limits, readable by LLVM 23 and newer.
21 V2,
22}
23
24impl GsymVersion {
25 /// Returns the version number stored in a GSYM header.
26 #[must_use]
27 pub const fn number(self) -> u16 {
28 match self {
29 Self::V1 => 1,
30 Self::V2 => 2,
31 }
32 }
33}
34
35impl std::fmt::Display for GsymVersion {
36 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 write!(formatter, "v{}", self.number())
38 }
39}