Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ repository = "https://github.com/ATLAS-Space-Operations/rust-freedom-models"
[dependencies]
ipnet = { version = "2.11.0" }
strum = { version = "0.25.0", features = ["derive"] }
thiserror = { version = "1.0.56" }
time = { version = "0.3.36", features = ["serde-human-readable", "macros"] }
time = { version = "0.3.36" }
url = { version = "2.5.0" }

# Optional dependencies
Expand All @@ -21,6 +20,7 @@ serde_with = { version = "3.3.0", optional = true }

[dev-dependencies]
serde_json = { version = "1.0.111" }
time = { version = "0.3.36", features = ["macros"] }

[features]
serde = ["dep:serde", "dep:serde_with", "url/serde", "ipnet/json"]
serde = ["dep:serde", "dep:serde_with", "url/serde", "ipnet/json", "time/serde-human-readable"]
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
[![Crates.io](https://img.shields.io/crates/v/freedom-models.svg)](https://crates.io/crates/freedom-models)
[![Documentation](https://docs.rs/freedom-models/badge.svg)](https://docs.rs/freedom-models/)

Contains rust data structures which map to Freedom resources to simplify usage
of the API
Contains data structures which map to Freedom resources to simplify usage
of the [Freedom API](https://github.com/ATLAS-Space-Operations/rust-freedom-api)

## HATEOAS Trait

In addition, the library exposes a single trait `Hateoas`. This is
useful for navigating the
[HATEOAS](https://en.wikipedia.org/wiki/HATEOAS) structure of the API.
24 changes: 17 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
#[cfg(feature = "serde")]
use serde::Deserialize;
use thiserror::Error;

#[cfg_attr(
feature = "serde",
derive(Deserialize),
serde(rename_all = "camelCase")
)]
#[derive(Debug, Clone, Error, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
#[error("An item within the inner paginated structure failed to deserialize")]
PaginatedInner,

#[error("The inner list of paginated elements is missing")]
PaginatedListMissing,

#[error("The link map failed to deserialize: {0}")]
Link(String),
}

impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::PaginatedInner => {
f.write_str("An item within the inner paginated structure failed to deserialize")
}
Error::PaginatedListMissing => {
f.write_str("The inner list of paginated elements is missing")
}
Error::Link(inner) => write!(f, "The link map failed to deserialize: {inner}"),
}
}
}

impl core::error::Error for Error {}
1 change: 0 additions & 1 deletion src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ mod tests {
use super::*;

#[test]
#[cfg(feature = "serde")]
fn deserialize() {
let json_value = r#"{
"site": {
Expand Down
2 changes: 0 additions & 2 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ mod tests {
use super::*;

#[test]
#[cfg(feature = "serde")]
fn task_status_event() {
let json = r#"
{
Expand Down Expand Up @@ -267,7 +266,6 @@ mod tests {
}

#[test]
#[cfg(feature = "serde")]
fn task_status_event_float_timestamp() {
use time::macros::datetime;

Expand Down