From b7b1daaa7d529c877b4a6f7870dedc27193ae154 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Sat, 16 Dec 2023 09:44:18 -0700 Subject: [PATCH 1/5] refactor: rename package 'hc_prefix_index' --- Cargo.lock | 22 +++++++++---------- Cargo.toml | 2 +- dnas/demo/zomes/coordinator/demo/Cargo.toml | 2 +- .../coordinator/demo/src/demo_prefix_index.rs | 2 +- dnas/demo/zomes/integrity/demo/Cargo.toml | 3 +-- dnas/demo/zomes/integrity/demo/src/lib.rs | 2 +- lib/prefix_index/Cargo.toml | 4 ++-- lib/prefix_index/src/validate.rs | 1 - 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bae1249..204f0f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1219,9 +1219,9 @@ name = "demo" version = "0.2.0" dependencies = [ "demo_integrity", + "hc_prefix_index", "hdk", "holochain", - "prefix_index", "serde", "tokio", ] @@ -1230,8 +1230,8 @@ dependencies = [ name = "demo_integrity" version = "0.2.0" dependencies = [ + "hc_prefix_index", "hdi", - "prefix_index", "serde", ] @@ -1983,6 +1983,15 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "hc_prefix_index" +version = "0.8.0" +dependencies = [ + "hdk", + "rand 0.8.5", + "serde", +] + [[package]] name = "hc_seed_bundle" version = "0.1.7" @@ -4575,15 +4584,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "prefix_index" -version = "0.8.0" -dependencies = [ - "hdk", - "rand 0.8.5", - "serde", -] - [[package]] name = "pretty_assertions" version = "0.7.2" diff --git a/Cargo.toml b/Cargo.toml index b7a9f4b..e07edaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,5 +23,5 @@ path = "dnas/demo/zomes/coordinator/demo" [workspace.dependencies.demo_integrity] path = "dnas/demo/zomes/integrity/demo" -[workspace.dependencies.prefix_index] +[workspace.dependencies.hc_prefix_index] path = "lib/prefix_index" diff --git a/dnas/demo/zomes/coordinator/demo/Cargo.toml b/dnas/demo/zomes/coordinator/demo/Cargo.toml index 68c69e0..184afb5 100644 --- a/dnas/demo/zomes/coordinator/demo/Cargo.toml +++ b/dnas/demo/zomes/coordinator/demo/Cargo.toml @@ -11,7 +11,7 @@ name = "demo" hdk = { workspace = true } serde = { workspace = true } demo_integrity = { workspace = true } -prefix_index = { workspace = true } +hc_prefix_index = { workspace = true } [dev-dependencies] hdk = { workspace = true, features = ["encoding", "test_utils"] } diff --git a/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs b/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs index 5343080..6bc834c 100644 --- a/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs +++ b/dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs @@ -1,6 +1,6 @@ use demo_integrity::*; +use hc_prefix_index::PrefixIndex; use hdk::prelude::*; -use prefix_index::PrefixIndex; #[hdk_extern] pub fn add_to_index_a(text: String) -> ExternResult<()> { diff --git a/dnas/demo/zomes/integrity/demo/Cargo.toml b/dnas/demo/zomes/integrity/demo/Cargo.toml index 1f65cc2..96c5611 100644 --- a/dnas/demo/zomes/integrity/demo/Cargo.toml +++ b/dnas/demo/zomes/integrity/demo/Cargo.toml @@ -9,6 +9,5 @@ name = "demo_integrity" [dependencies] hdi = { workspace = true } - serde = { workspace = true } -prefix_index = { workspace = true } \ No newline at end of file +hc_prefix_index = { workspace = true } diff --git a/dnas/demo/zomes/integrity/demo/src/lib.rs b/dnas/demo/zomes/integrity/demo/src/lib.rs index 8ca2389..040bc3f 100644 --- a/dnas/demo/zomes/integrity/demo/src/lib.rs +++ b/dnas/demo/zomes/integrity/demo/src/lib.rs @@ -1,5 +1,5 @@ +use hc_prefix_index::PrefixIndex; use hdi::prelude::*; -use prefix_index::PrefixIndex; pub const PREFIX_INDEX_A_NAME: &str = "prefix_index_a"; pub const PREFIX_INDEX_A_WIDTH: usize = 3; diff --git a/lib/prefix_index/Cargo.toml b/lib/prefix_index/Cargo.toml index 8b7e85e..1dd065f 100644 --- a/lib/prefix_index/Cargo.toml +++ b/lib/prefix_index/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "prefix_index" +name = "hc_prefix_index" version = "0.8.0" edition = "2021" [lib] crate-type = ["cdylib", "rlib"] -name = "prefix_index" +name = "hc_prefix_index" [dependencies] hdk = { workspace = true } diff --git a/lib/prefix_index/src/validate.rs b/lib/prefix_index/src/validate.rs index 23ef6af..957e77a 100644 --- a/lib/prefix_index/src/validate.rs +++ b/lib/prefix_index/src/validate.rs @@ -1,4 +1,3 @@ -//use crate::PREFIX_INDEX_WIDTH; use crate::PrefixIndex; use hdk::hash_path::path::{root_hash, Component}; use hdk::prelude::*; From c13f212b0f2493cdcc283b26eb2a2727e6851d3b Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Sat, 16 Dec 2023 09:44:57 -0700 Subject: [PATCH 2/5] chore: move package dir to match name --- Cargo.toml | 2 +- lib/{prefix_index => hc_prefix_index}/Cargo.toml | 0 lib/{prefix_index => hc_prefix_index}/src/lib.rs | 0 lib/{prefix_index => hc_prefix_index}/src/prefix_index.rs | 0 lib/{prefix_index => hc_prefix_index}/src/types.rs | 0 lib/{prefix_index => hc_prefix_index}/src/utils.rs | 0 lib/{prefix_index => hc_prefix_index}/src/validate.rs | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename lib/{prefix_index => hc_prefix_index}/Cargo.toml (100%) rename lib/{prefix_index => hc_prefix_index}/src/lib.rs (100%) rename lib/{prefix_index => hc_prefix_index}/src/prefix_index.rs (100%) rename lib/{prefix_index => hc_prefix_index}/src/types.rs (100%) rename lib/{prefix_index => hc_prefix_index}/src/utils.rs (100%) rename lib/{prefix_index => hc_prefix_index}/src/validate.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index e07edaa..3c26009 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,4 @@ path = "dnas/demo/zomes/coordinator/demo" path = "dnas/demo/zomes/integrity/demo" [workspace.dependencies.hc_prefix_index] -path = "lib/prefix_index" +path = "lib/hc_prefix_index" diff --git a/lib/prefix_index/Cargo.toml b/lib/hc_prefix_index/Cargo.toml similarity index 100% rename from lib/prefix_index/Cargo.toml rename to lib/hc_prefix_index/Cargo.toml diff --git a/lib/prefix_index/src/lib.rs b/lib/hc_prefix_index/src/lib.rs similarity index 100% rename from lib/prefix_index/src/lib.rs rename to lib/hc_prefix_index/src/lib.rs diff --git a/lib/prefix_index/src/prefix_index.rs b/lib/hc_prefix_index/src/prefix_index.rs similarity index 100% rename from lib/prefix_index/src/prefix_index.rs rename to lib/hc_prefix_index/src/prefix_index.rs diff --git a/lib/prefix_index/src/types.rs b/lib/hc_prefix_index/src/types.rs similarity index 100% rename from lib/prefix_index/src/types.rs rename to lib/hc_prefix_index/src/types.rs diff --git a/lib/prefix_index/src/utils.rs b/lib/hc_prefix_index/src/utils.rs similarity index 100% rename from lib/prefix_index/src/utils.rs rename to lib/hc_prefix_index/src/utils.rs diff --git a/lib/prefix_index/src/validate.rs b/lib/hc_prefix_index/src/validate.rs similarity index 100% rename from lib/prefix_index/src/validate.rs rename to lib/hc_prefix_index/src/validate.rs From 7ffae88a3e1e06d5be15c6ae7b20bba2b48e3782 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Sat, 16 Dec 2023 09:45:35 -0700 Subject: [PATCH 3/5] build: bump package version --- Cargo.lock | 2 +- lib/hc_prefix_index/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 204f0f4..e810dc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1985,7 +1985,7 @@ dependencies = [ [[package]] name = "hc_prefix_index" -version = "0.8.0" +version = "0.9.0" dependencies = [ "hdk", "rand 0.8.5", diff --git a/lib/hc_prefix_index/Cargo.toml b/lib/hc_prefix_index/Cargo.toml index 1dd065f..a8b984f 100644 --- a/lib/hc_prefix_index/Cargo.toml +++ b/lib/hc_prefix_index/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hc_prefix_index" -version = "0.8.0" +version = "0.9.0" edition = "2021" [lib] From 63c5d133e6cf251fa26843a391bd6d4bf2347c78 Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Sat, 16 Dec 2023 09:46:02 -0700 Subject: [PATCH 4/5] doc: changelog --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20093d1..79cc8cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,26 @@ All notable changes to this project will be documented in this file. +## [0.9.0] - 2023-12-16 + +### Miscellaneous Tasks + +- Move package dir to match name + +### Refactor + +- Rename package 'hc_prefix_index' + +### Build + +- Bump package version + ## [0.8.0] - 2023-12-16 ### Documentation - Add changelog +- Changelog ### Miscellaneous Tasks From 26dc0c092b270bdc5c06d9f85fab68d6193ffd1e Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Sat, 16 Dec 2023 09:49:23 -0700 Subject: [PATCH 5/5] doc: update readme --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8f86dfe..e56dcb8 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,17 @@ A prefix index is useful for typeahead "search" functionality. ## Usage -1. Include the prefix_index crate in your coordinator zome's Cargo.toml: +1. Include the hc_prefix_index crate in your coordinator zome's Cargo.toml: ```toml [dependencies] ... -prefix_index = { git = "https://github.com/mattyg/holochain-prefix-index" module = "prefix_index" } +hc_prefix_index = "=0.9.0" ``` -2. Include the prefix_index crate in your integrity zome's Cargo.toml and create a link type for the index: +2. Include the hc_prefix_index crate in your integrity zome's Cargo.toml + +3. Create a link type for the index: ```rust #[hdk_link_types] enum LinkTypes { @@ -22,9 +24,9 @@ enum LinkTypes { } ``` -3. Add the prefix index validation functions to your validate match arm for CreateLink and DeleteLink on LinkTypes::PrefixIndex +4. Add the prefix index validation functions to your validate match arm for CreateLink and DeleteLink on LinkTypes::PrefixIndex -3. Setup a prefix index +5. Setup a prefix index ```rust use prefix_index::PrefixIndex; @@ -32,7 +34,7 @@ use prefix_index::PrefixIndex; let index = PrefixIndex::new("demo_index".into(), LinkTypes::PrefixIndex, 3, 3)?; ``` -4. Add some results to the index: +6. Add some results to the index: ```rust index.add_result("superdupercool"); index.add_result("superdupercrazy"); @@ -42,7 +44,7 @@ index.add_result("SUPERDUPER"); ``` -5. This will generate an index of links for the strings as follows: +7. This will generate an index of links for the strings as follows: ```mermaid flowchart LR @@ -54,7 +56,7 @@ flowchart LR B --> J[ers] --> K[atu] --> L[supersaturates] ``` -6. Now you can search the index using DFS. +8. Now you can search the index using DFS. ```rust index.get_results("sup", 10); // [