@@ -6,33 +6,35 @@ A prefix index is useful for typeahead "search" functionality.
66
77## Usage
88
9- 1 . Include the prefix_index crate in your coordinator zome's Cargo.toml:
9+ 1 . Include the hc_prefix_index crate in your coordinator zome's Cargo.toml:
1010
1111``` toml
1212[dependencies ]
1313...
14- prefix_index = { git = " https://github.com/mattyg/holochain-prefix-index " module = " prefix_index " }
14+ hc_prefix_index = " =0.9.0 "
1515```
1616
17- 2 . Include the prefix_index crate in your integrity zome's Cargo.toml and create a link type for the index:
17+ 2 . Include the hc_prefix_index crate in your integrity zome's Cargo.toml
18+
19+ 3 . Create a link type for the index:
1820``` rust
1921#[hdk_link_types]
2022enum LinkTypes {
2123 PrefixIndex
2224}
2325```
2426
25- 3 . Add the prefix index validation functions to your validate match arm for CreateLink and DeleteLink on LinkTypes::PrefixIndex
27+ 4 . Add the prefix index validation functions to your validate match arm for CreateLink and DeleteLink on LinkTypes::PrefixIndex
2628
27- 3 . Setup a prefix index
29+ 5 . Setup a prefix index
2830
2931``` rust
3032use prefix_index :: PrefixIndex ;
3133
3234let index = PrefixIndex :: new (" demo_index" . into (), LinkTypes :: PrefixIndex , 3 , 3 )? ;
3335```
3436
35- 4 . Add some results to the index:
37+ 6 . Add some results to the index:
3638``` rust
3739index . add_result (" superdupercool" );
3840index . add_result (" superdupercrazy" );
@@ -42,7 +44,7 @@ index.add_result("SUPERDUPER");
4244
4345```
4446
45- 5 . This will generate an index of links for the strings as follows:
47+ 7 . This will generate an index of links for the strings as follows:
4648
4749``` mermaid
4850flowchart LR
@@ -54,7 +56,7 @@ flowchart LR
5456 B --> J[ers] --> K[atu] --> L[supersaturates]
5557```
5658
57- 6 . Now you can search the index using DFS.
59+ 8 . Now you can search the index using DFS.
5860``` rust
5961index . get_results (" sup" , 10 );
6062// [
0 commit comments