| 22 | |
| 23 | template<typename R> |
| 24 | static Valdi::Result<R> processImage(const Valdi::StringBox& imageFilePath, |
| 25 | ProcessImageFn<R>&& defaultHandler, |
| 26 | ProcessImageFn<R>&& svgHandler) { |
| 27 | Valdi::Path path(imageFilePath.toStringView()); |
| 28 | auto loadResult = Valdi::DiskUtils::load(path); |
| 29 | if (!loadResult) { |
| 30 | return loadResult.moveError(); |
| 31 | } |
| 32 | |
| 33 | auto fileBytes = loadResult.moveValue(); |
| 34 | |
| 35 | if (path.getFileExtension() == "svg") { |
| 36 | return svgHandler(fileBytes); |
| 37 | } else { |
| 38 | return defaultHandler(fileBytes); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | static Valdi::Result<Ref<Image>> loadImage(const Valdi::StringBox& imageFilePath, |
| 43 | const std::optional<int>& widthHint, |
nothing calls this directly
no test coverage detected