Last active
November 16, 2022 10:02
-
-
Save mebjas/f1f23b3e550a3d0290b448e89107122e to your computer and use it in GitHub Desktop.
Updated interface of image library with method to decode Image from string image buffer.
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
class ImageFactory { | |
public: | |
// Decodes the `image_buffer` and returns Image instance. | |
// | |
// Suggestion for readers: Use absl::string_view instead of string here. | |
static std::unique_ptr<Image> FromString(const std::string& image_buffer); | |
// Creates an instance of 'Image' from the file descriptor 'fd'. | |
// | |
// Will return 'nullptr' if it's unable to decode image successfully. | |
// | |
// Note for readers: If you can add abseil package to your code base, I | |
// recommend changing this API to return | |
// 'absl::StatusOr<std::unique_ptr<Image>>' instead. This will lead to much | |
// cleaner API and improved error handling. | |
static std::unique_ptr<Image> FromFd(int fd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment