---
source: tests/backends_swift_snapshot_test.rs
expression: "&file.content"
---
// Generated by alef. Do not edit by hand.
// swift-format-ignore-file
// This file contains generated FFI glue for plugin Box classes.

import Foundation
import RustBridge

/// Opaque box class retained by Rust via `Unmanaged<SwiftImageProcessorBox>.passRetained`.
/// Wraps `any SwiftImageProcessorBridge` and exposes `alef_*` FFI shim methods.
/// swift-bridge @_cdecl shims call these methods directly.
public final class SwiftImageProcessorBox {
    private let bridge: any SwiftImageProcessorBridge
    public init(_ bridge: any SwiftImageProcessorBridge) { self.bridge = bridge }
    // MARK: Plugin super-trait shims

    public func alef_name() -> RustString {
        return RustString(bridge.name)
    }

    public func alef_version() -> RustString {
        return RustString(bridge.version())
    }

    public func alef_initialize() -> String {
        do {
            try bridge.initialize()
            return encodeOkVoidEnvelope()
        } catch { return encodeErrEnvelope("\(error)") }
    }

    public func alef_shutdown() -> String {
        do {
            try bridge.shutdown()
            return encodeOkVoidEnvelope()
        } catch { return encodeErrEnvelope("\(error)") }
    }

    // MARK: Trait-specific shims
    public func alef_process_image(image_bytes imageBytes: RustVec<UInt8>, config: RustString) -> String {
        do {
          let result = try bridge.processImage(imageBytes: Data(imageBytes), config: config.toString())
          return encodeOkEnvelope(result)
        } catch { return encodeErrEnvelope("\(error)") }
    }
    public func alef_supports_language(lang: RustString) -> Bool {
        return bridge.supportsLanguage(lang: lang.toString())
    }
}
