Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions rust/bridge/image_type_recognition_cpp_api_shim.cc
Original file line number Diff line number Diff line change
@@ -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 <cstddef>

#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
53 changes: 53 additions & 0 deletions rust/bridge/piex_cpp_api_shim.cc
Original file line number Diff line number Diff line change
@@ -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 <cstddef>
#include <cstdint>
#include <string>
#include <vector>

#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<std::uint32_t>* 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<std::string> 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