diff options
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()); + } +} |