diff --git a/rust/bridge/image_type_recognition_cpp_api_shim.cc b/rust/bridge/image_type_recognition_cpp_api_shim.cc new file mode 100644 index 0000000..dee1d36 --- /dev/null +++ b/rust/bridge/image_type_recognition_cpp_api_shim.cc @@ -0,0 +1,42 @@ +// Copyright 2026 Google LLC +// +// Drop-in C++ replacement entry points for piex::image_type_recognition, +// forwarding to the Rust implementation in piex_rust::image_type_recognition. + +#include + +#include "rust/include/piex_rust.h" +#include "src/binary_parse/range_checked_byte_ptr.h" +#include "src/image_type_recognition/image_type_recognition_lite.h" + +namespace piex { +namespace image_type_recognition { + +bool IsRaw(RawImageTypes type) { + return ::piex_rust::image_type_recognition::IsRaw(type); +} + +bool IsOfType(const binary_parse::RangeCheckedBytePtr& source, + RawImageTypes type) { + return ::piex_rust::image_type_recognition::IsOfType(source, type); +} + +RawImageTypes RecognizeRawImageTypeLite( + const binary_parse::RangeCheckedBytePtr& source) { + return ::piex_rust::image_type_recognition::RecognizeRawImageTypeLite(source); +} + +size_t GetNumberOfBytesForIsRawLite() { + return ::piex_rust::image_type_recognition::GetNumberOfBytesForIsRawLite(); +} + +size_t GetNumberOfBytesForIsOfType(RawImageTypes type) { + return ::piex_rust::image_type_recognition::GetNumberOfBytesForIsOfType(type); +} + +bool IsRawLite(const binary_parse::RangeCheckedBytePtr& source) { + return ::piex_rust::image_type_recognition::IsRawLite(source); +} + +} // namespace image_type_recognition +} // namespace piex diff --git a/rust/bridge/piex_cpp_api_shim.cc b/rust/bridge/piex_cpp_api_shim.cc new file mode 100644 index 0000000..9bdb980 --- /dev/null +++ b/rust/bridge/piex_cpp_api_shim.cc @@ -0,0 +1,53 @@ +// Copyright 2026 Google LLC +// +// Drop-in C++ replacement entry points for namespace piex (piex.h and +// piex_cr3.h), forwarding to the Rust implementation in namespace piex_rust. + +#include +#include +#include +#include + +#include "rust/include/piex_rust.h" +#include "src/image_type_recognition/image_type_recognition_lite.h" +#include "src/piex.h" +#include "src/piex_cr3.h" +#include "src/piex_types.h" + +namespace piex { + +size_t BytesRequiredForIsRaw() { return ::piex_rust::BytesRequiredForIsRaw(); } + +bool IsRaw(StreamInterface* data) { return ::piex_rust::IsRaw(data); } + +Error GetPreviewImageData(StreamInterface* data, + PreviewImageData* preview_image_data, + image_type_recognition::RawImageTypes* output_type) { + return ::piex_rust::GetPreviewImageData(data, preview_image_data, + output_type); +} + +bool GetDngInformation(StreamInterface* data, std::uint32_t* width, + std::uint32_t* height, + std::vector* cfa_pattern_dim) { + return ::piex_rust::GetDngInformation(data, width, height, cfa_pattern_dim); +} + +bool GetOrientation(StreamInterface* data, std::uint32_t* orientation) { + return ::piex_rust::GetOrientation(data, orientation); +} + +std::vector SupportedExtensions() { + return ::piex_rust::SupportedExtensions(); +} + +bool Cr3GetOrientation(StreamInterface* stream, std::uint32_t* orientation) { + return ::piex_rust::Cr3GetOrientation(stream, orientation); +} + +Error Cr3GetPreviewData(StreamInterface* stream, + PreviewImageData* preview_image_data) { + return ::piex_rust::Cr3GetPreviewData(stream, preview_image_data); +} + +} // namespace piex