caniuse_serde/
VersionDetail.rs

1// This file is part of caniuse-serde. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/caniuse-serde/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of caniuse-serde. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/caniuse-serde/master/COPYRIGHT.
3
4
5/// Details about a particular version, of which only the release_date is particularly useful.
6/// The era is a relative value which can change with releases of the caniuse.com database, and the global_usage can differ to that available in `RegionalUsage::WorldWide`.
7#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
8pub struct VersionDetail
9{
10	global_usage: UsagePercentage,
11	release_date: Option<DateTime<Utc>>,
12	era: i64,
13	prefix_override: Option<Prefix>,
14}
15
16impl VersionDetail
17{
18	/// A global usage of this version; one of three measurements included in the caniuse.com database.
19	/// It is recommended to use that in the `RegionalUsage::WorldWide` database instead as RegionalUsage data has greater consistency.
20	#[inline(always)]
21	pub fn global_usage(&self) -> UsagePercentage
22	{
23		self.global_usage
24	}
25	
26	/// A timestamp of when this particular version was released.
27	/// It is likely that the hours, minutes and seconds represent false precision.
28	/// If the release_date is None, then ordinarily this version has not yet been released and `self.era()` should be greater than zero (0).
29	#[inline(always)]
30	pub fn release_date(&self) -> Option<DateTime<Utc>>
31	{
32		self.release_date
33	}
34	
35	/// Eras are the caniuse.com database's attempt to align different browsers by version.
36	/// Negative values are for not current versions.
37	/// Zero is for the current version.
38	/// The era is a relative value which which can change with releases of the caniuse.com database.
39	#[inline(always)]
40	pub fn era(&self) -> i64
41	{
42		self.era
43	}
44	
45	/// Override of prefix; only specified for Opera
46	#[inline(always)]
47	pub fn prefix_override(&self) -> Option<&Prefix>
48	{
49		self.prefix_override.as_ref()
50	}
51}