Crate marisa_ffi

Crate marisa_ffi 

Source
Expand description

§Marisa FFI Rust Bindings

This crate provides Rust bindings for the libmarisa library, a space-efficient trie data structure.

§Features

  • Lookup: Check whether a string exists in the dictionary
  • Reverse lookup: Restore a key from its ID
  • Common prefix search: Find keys from prefixes of a given string
  • Predictive search: Find keys starting with a given string

§Example

use marisa_ffi::{Trie, Keyset, Agent};

// Create a keyset and add some keys
let mut keyset = Keyset::new().unwrap();
keyset.push("hello").unwrap();
keyset.push("world").unwrap();

// Build the trie
let trie = Trie::build(&keyset).unwrap();

// Lookup a key
if let Some(id) = trie.lookup("hello") {
    println!("Found 'hello' with ID: {}", id);
}

// Predictive search
let mut agent = Agent::new().unwrap();
if trie.predictive_search("h", &mut agent).unwrap() {
    println!("Found key: {}", agent.key().unwrap());
}

Structs§

Agent
An agent for search operations
Keyset
A keyset for building tries
Trie
A Marisa trie for efficient string storage and lookup

Enums§

MarisaError
Error type for Marisa operations

Functions§

strerror
Get a human-readable error message
version
Get the version string of the Marisa library