-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #3, performance and code improvements.
- Loading branch information
1 parent
7522fd3
commit f0cf712
Showing
5 changed files
with
83 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
use bytes::Bytes; | ||
use chrono::{DateTime, FixedOffset}; | ||
use image::DynamicImage; | ||
|
||
pub struct Book { | ||
pub name: String, | ||
pub category: String, | ||
pub image: DynamicImage, | ||
pub date_added: DateTime<FixedOffset>, | ||
pub raw_bytes: Bytes, | ||
} | ||
|
||
impl Book { | ||
pub fn to_image(&self) -> DynamicImage { | ||
image::load_from_memory(&self.raw_bytes).expect("Failed to convert bytes into image.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters