alef 0.23.13

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{%- if doc %}
{{ doc }}{%- endif %}
public final class {{ class_name }} {

    private var inner: RustBridge.{{ class_name }}?

    /// Retained handler boxes. Each box is passed to the C layer as the
    /// trampoline context pointer and released in `deinit` to avoid leaks.
    private var handlerBoxes: [UnsafeMutableRawPointer] = []

    /// Boxes a handler closure so it can travel through a C context pointer.
    private final class HandlerBox {
        let handler: (String) -> String
        init(_ handler: @escaping (String) -> String) { self.handler = handler }
    }