Skip to content

Commit 74eef5a

Browse files
committed
feat: Add unstable feature flag
1 parent a587d8c commit 74eef5a

16 files changed

Lines changed: 58 additions & 43 deletions

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ time = { version = "0.3.36", features = ["macros"] }
2424

2525
[features]
2626
serde = ["dep:serde", "dep:serde_with", "url/serde", "ipnet/json", "time/serde-human-readable"]
27+
unstable = []

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,17 @@ of the [Freedom API](https://github.com/ATLAS-Space-Operations/rust-freedom-api)
1111
In addition, the library exposes a single trait `Hateoas`. This is
1212
useful for navigating the
1313
[HATEOAS](https://en.wikipedia.org/wiki/HATEOAS) structure of the API.
14+
15+
## Unstable Flag
16+
17+
By default, all public structs in the crate are marked
18+
`non_exhaustive`. This is because we may--at any time--add a field to
19+
one or more of the structs, and this should not constitute a breaking
20+
change for users.
21+
22+
However, for users who would like to construct the models for testing
23+
purposes or as their baseline we do provide the `unstable` feature
24+
flag, which disables this behavior when set.
25+
26+
By using the `unstable` flag you accept that your construction of
27+
models might break between releases.

src/account.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::utils;
2020
serde(rename_all = "camelCase")
2121
)]
2222
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
23-
#[non_exhaustive]
23+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
2424
pub struct AccountCidr {
2525
pub name: String,
2626
pub cidr: Ipv4Net,
@@ -40,7 +40,7 @@ impl std::ops::Deref for AccountCidr {
4040
serde(rename_all = "camelCase")
4141
)]
4242
#[derive(Debug, Clone, PartialEq)]
43-
#[non_exhaustive]
43+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
4444
pub struct Tier {
4545
pub tier: u32,
4646
pub price: f32,
@@ -68,7 +68,7 @@ impl Hateoas for Tier {
6868
serde(rename_all = "camelCase")
6969
)]
7070
#[derive(Debug, Clone, PartialEq)]
71-
#[non_exhaustive]
71+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
7272
pub struct Account {
7373
#[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
7474
pub created: OffsetDateTime,

src/azel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use time::OffsetDateTime;
88
serde(rename_all = "camelCase")
99
)]
1010
#[derive(Debug, Clone, PartialEq)]
11-
#[non_exhaustive]
11+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
1212
pub struct Location {
1313
pub longitude: f64,
1414
pub latitude: f64,
@@ -21,7 +21,7 @@ pub struct Location {
2121
serde(rename_all = "camelCase")
2222
)]
2323
#[derive(Debug, Clone, PartialEq)]
24-
#[non_exhaustive]
24+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
2525
pub struct Direction {
2626
#[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
2727
pub timestamp: OffsetDateTime,
@@ -35,7 +35,7 @@ pub struct Direction {
3535
serde(rename_all = "camelCase")
3636
)]
3737
#[derive(Debug, Clone, PartialEq)]
38-
#[non_exhaustive]
38+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
3939
pub struct AzEl {
4040
#[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
4141
pub start: OffsetDateTime,

src/band.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use super::utils;
1717
)]
1818
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, AsRefStr, EnumString)]
1919
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
20-
#[non_exhaustive]
20+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
2121
pub enum BandType {
2222
Transmit,
2323
Receive,
@@ -30,7 +30,7 @@ pub enum BandType {
3030
)]
3131
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, AsRefStr, EnumString)]
3232
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
33-
#[non_exhaustive]
33+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
3434
pub enum IoHardware {
3535
Modem,
3636
Fep,
@@ -47,7 +47,7 @@ pub enum IoHardware {
4747
serde(rename_all = "camelCase")
4848
)]
4949
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
50-
#[non_exhaustive]
50+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
5151
pub struct IoConfiguration {
5252
#[cfg_attr(feature = "serde", serde(default))]
5353
pub start_hex_pattern: Option<String>,
@@ -64,7 +64,7 @@ pub struct IoConfiguration {
6464
serde(rename_all = "camelCase")
6565
)]
6666
#[derive(Debug, Clone, PartialEq)]
67-
#[non_exhaustive]
67+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
6868
pub struct Band {
6969
#[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
7070
pub created: OffsetDateTime,

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use serde::Deserialize;
77
serde(rename_all = "camelCase")
88
)]
99
#[derive(Debug, Clone, PartialEq, Eq)]
10-
#[non_exhaustive]
10+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
1111
pub enum Error {
1212
PaginatedInner,
1313
PaginatedListMissing,

src/gateway_licenses.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use time::OffsetDateTime;
1212
serde(rename_all = "camelCase")
1313
)]
1414
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
15-
#[non_exhaustive]
15+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
1616
pub struct RegenerateResponse {
1717
pub account_id: u64,
1818
pub license_id: u32,
@@ -28,7 +28,7 @@ pub struct RegenerateResponse {
2828
serde(rename_all = "camelCase")
2929
)]
3030
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
31-
#[non_exhaustive]
31+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
3232
pub struct VerifyResponse {
3333
pub valid: bool,
3434
pub license_id: Option<u32>,
@@ -50,7 +50,7 @@ pub struct VerifyResponse {
5050
serde(rename_all = "camelCase")
5151
)]
5252
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
53-
#[non_exhaustive]
53+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
5454
pub struct View(pub Vec<ViewOne>);
5555

5656
/// Representation of a single license associated with an account.
@@ -62,7 +62,7 @@ pub struct View(pub Vec<ViewOne>);
6262
serde(rename_all = "camelCase")
6363
)]
6464
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
65-
#[non_exhaustive]
65+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
6666
pub struct ViewOne {
6767
pub id: u32,
6868
pub account_id: u64,
@@ -92,7 +92,7 @@ pub struct ViewOne {
9292
)]
9393
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, AsRefStr, EnumString)]
9494
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
95-
#[non_exhaustive]
95+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
9696
pub enum Status {
9797
/// License is active and can be used.
9898
Active,

src/pagination.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use url::Url;
99
/// A paginated response
1010
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
1111
#[serde(rename_all = "camelCase")]
12-
#[non_exhaustive]
12+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
1313
pub struct Paginated<T>
1414
where
1515
T: DeserializeOwned,
@@ -39,7 +39,7 @@ where
3939
/// Page metadata included in a paginated stream
4040
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
4141
#[serde(rename_all = "camelCase")]
42-
#[non_exhaustive]
42+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
4343
pub struct Page {
4444
pub size: u32,
4545
pub total_elements: u32,

src/satellite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::utils;
1515
serde(rename_all = "camelCase")
1616
)]
1717
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
18-
#[non_exhaustive]
18+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
1919
pub struct TwoLineElement {
2020
pub line1: String,
2121
pub line2: String,
@@ -28,7 +28,7 @@ pub struct TwoLineElement {
2828
serde(rename_all = "camelCase")
2929
)]
3030
#[derive(Debug, Clone, PartialEq, Eq)]
31-
#[non_exhaustive]
31+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
3232
pub struct Satellite {
3333
#[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
3434
pub created: OffsetDateTime,

src/satellite_configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::utils;
1616
serde(rename_all = "camelCase")
1717
)]
1818
#[derive(Debug, Clone, PartialEq, Eq)]
19-
#[non_exhaustive]
19+
#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
2020
pub struct SatelliteConfiguration {
2121
#[cfg_attr(feature = "serde", serde(with = "time::serde::iso8601"))]
2222
pub created: OffsetDateTime,

0 commit comments

Comments
 (0)