1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! C-compatible FFI for liblevenshtein.
//!
//! This module provides raw C-compatible functions (`extern "C"`) for use with:
//! - WASI runtimes (Wasmtime, WasmEdge)
//! - Native FFI from other languages (Python, Ruby, Go, etc.)
//!
//! # Memory Management
//!
//! All strings returned by FFI functions must be freed using [`llev_string_free`].
//! All arrays returned must be freed using their specific free function.
//!
//! # Safety
//!
//! All FFI functions are unsafe as they operate on raw pointers. Callers must:
//! - Ensure pointers are valid and non-null
//! - Free returned memory using the appropriate free function
//! - Not use freed pointers
//!
//! # Example (C)
//!
//! ```c
//! #include <liblevenshtein.h>
//!
//! int main() {
//! // Calculate distance
//! size_t dist = llev_distance("hello", 5, "helo", 4);
//! printf("Distance: %zu\n", dist);
//!
//! // Create dictionary
//! const char* terms[] = {"hello", "help", "world"};
//! LlevDictionary* dict = llev_dict_new(terms, 3);
//!
//! // Create transducer
//! LlevTransducer* trans = llev_transducer_new(dict, LLEV_ALGORITHM_STANDARD);
//!
//! // Query
//! LlevCandidateArray results = llev_transducer_query(trans, "helo", 4, 2);
//! for (size_t i = 0; i < results.len; i++) {
//! printf("%s: %zu\n", results.data[i].term, results.data[i].distance);
//! }
//!
//! // Cleanup
//! llev_candidates_free(results);
//! llev_transducer_free(trans);
//! llev_dict_free(dict);
//!
//! return 0;
//! }
//! ```
pub use *;
pub use *;
use ;
/// Algorithm type for transducers.
/// Convert a C string to a Rust string slice.
///
/// # Safety
///
/// The input pointer must be valid and null-terminated.
unsafe