diff options
author | Adam T. Carpenter <atc@53hor.net> | 2022-10-26 21:02:31 -0400 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2022-10-26 21:02:31 -0400 |
commit | 9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f (patch) | |
tree | db9ca419266117facecdff6d30460669f3148efb /src/lib.rs | |
parent | f243a3b7341012227d6e8342a65f9c5d7784256f (diff) | |
download | theglassyladies-9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f.tar.xz theglassyladies-9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f.zip |
init: add some stories and personas and begin layout out domain
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..0eb08b7 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,76 @@ +use std::collections::HashSet; + +// As an artist, I can upload artwork and attach it to a product +// As an artist, I can enter detailed information about a product +// As an artist, I can store a product for later recall by me or connoisseurs. +// As a connoisseur, I can search the gallery for artwork matching given keywords and see products +// containing that artwork +// As a connoisseur, I can select one or many products and submit them in a job to an artist + +// Sellable artwork +struct Product { + artwork: Artwork, + cents: u64, + quantity: u64, + featured: bool, +} + +impl Product { + fn dollars(&self) -> f64 { + self.cents as f64 / 100.0 + } +} + +struct Artwork { + name: String, + description: String, + category: Vec<String>, + tags: HashSet<String>, +} + +struct Customer {} + +struct Artist {} + +struct Search {} + +trait Gallery { + fn store(artwork: Artwork) -> Result<(), ()>; +} + +struct MockGallery {} + +impl Gallery for MockGallery { + fn store(_artwork: Artwork) -> Result<(), ()> { + Ok(()) + } +} + +struct Job {} + +fn add_two(a: usize, b: usize) -> usize { + a + b +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn add() { + assert_eq!(4, add_two(2, 2)); + } + + #[test] + fn dollars() { + let product = Product { + artwork: Artwork {}, + cents: 1000, + }; + assert_eq!(10.00, product.dollars()); + let product = Product { + artwork: Artwork {}, + cents: 1234, + }; + assert_eq!(12.34, product.dollars()); + } +} |