diff options
-rw-r--r-- | src/ship.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ship.rs b/src/ship.rs index 79253e1..bcb6981 100644 --- a/src/ship.rs +++ b/src/ship.rs @@ -10,7 +10,7 @@ use crate::{errors::Error, star::Star}; use serde::{Serialize, Deserialize}; /// Describes a hash of a file -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] pub struct Sha256(pub String); impl FromStr for Sha256 { @@ -41,6 +41,29 @@ pub struct Ship { pub version: String, } +/// Describes a starship generated from a database +#[derive(Serialize, Deserialize, Debug)] +pub struct DbShip { + /// The Database ID of the ship + pub id: i32, + + pub name: String, + pub shasum: Sha256, + pub download_url: String, + pub version: String +} + +impl From<DbShip> for Ship { + fn from(o: DbShip) -> Self { + Self { + name: o.name, + shasum: o.shasum, + download_url: o.download_url, + version: o.version + } + } +} + impl Ship { pub fn new(name: String, shasum: String, |