From 9f3098e80c6b6c87e9bfbfe36239a39e5cafb29f Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Wed, 26 Oct 2022 21:02:31 -0400 Subject: init: add some stories and personas and begin layout out domain --- src/lib.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/lib.rs (limited to 'src') 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, + tags: HashSet, +} + +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()); + } +} -- cgit v1.2.3