Refactor metadata to a more concise representation (#14)#15
Open
Refactor metadata to a more concise representation (#14)#15
Conversation
Collaborator
Author
|
The build failed, I will take a look later |
konikos
reviewed
Jul 4, 2022
| } | ||
|
|
||
| fn convert_exif_date_time_to_chrono_date_time_fixed_offset( | ||
| fn open_file(path: &Path, file_name: &String) -> Option<fs::File> { |
Collaborator
There was a problem hiding this comment.
I think we should use Result here as the return value because it already encodes the concept of an error case by design (same way you wouldn't return an Optional in Java instead of throwing an exception). By extension, I'd make read_metadata() return a Result.
Result also allows using ? which a nice way to chain function calls that return errors.
|
|
||
| fn convert_exif_date_time_to_chrono_date_time_fixed_offset( | ||
| fn open_file(path: &Path, file_name: &String) -> Option<fs::File> { | ||
| result_to_option(fs::File::open(path), "opening file ".to_owned() + file_name) |
Collaborator
There was a problem hiding this comment.
Apparently a more common way to format strings is format!()
Comment on lines
+132
to
+133
| .map(|file| get_exif_metadata(file, &file_name)) | ||
| .flatten() |
Collaborator
There was a problem hiding this comment.
flat map is called and_then() in Rust. This would have been nice if we remembered from scala 😅
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I wanted to play around with Rust and see if I can simplify a bit the extraction of the date time original and standardize the way we handle converting an error to an option.
What do you think?
Resolves #14