import 'dart:typed_data';

/// A pluggable local OCR backend.
///
/// Implementations turn a PNG image into recognized text. The app selects an
/// available backend via [OcrBackends]; absence of any backend is a clean
/// no-op (recognition returns null).
abstract class OcrBackend {
  /// Short identifier used for logging/selection (e.g. 'native', 'onnx').
  String get name;

  /// Whether this backend can run on the current device/build. May perform a
  /// lazy initialization attempt (e.g. loading a model) the first time.
  Future<bool> isAvailable();

  /// Recognize text from a PNG image. Returns null when nothing is recognized
  /// or the backend is unavailable. Implementations must never throw.
  Future<String?> recognize(Uint8List pngBytes);
}
