Skip to content

Commit

Permalink
Merge pull request #5 from holochain-open-dev/chore/publish-package
Browse files Browse the repository at this point in the history
rename package to 'hc_prefix_index'
  • Loading branch information
mattyg authored Dec 16, 2023
2 parents 1ac756b + 26dc0c0 commit c8bd3cc
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 30 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ path = "dnas/demo/zomes/coordinator/demo"
[workspace.dependencies.demo_integrity]
path = "dnas/demo/zomes/integrity/demo"

[workspace.dependencies.prefix_index]
path = "lib/prefix_index"
[workspace.dependencies.hc_prefix_index]
path = "lib/hc_prefix_index"
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@ 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 {
PrefixIndex
}
```

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;

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");
Expand All @@ -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
Expand All @@ -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);
// [
Expand Down
2 changes: 1 addition & 1 deletion dnas/demo/zomes/coordinator/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion dnas/demo/zomes/coordinator/demo/src/demo_prefix_index.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand Down
3 changes: 1 addition & 2 deletions dnas/demo/zomes/integrity/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ name = "demo_integrity"

[dependencies]
hdi = { workspace = true }

serde = { workspace = true }
prefix_index = { workspace = true }
hc_prefix_index = { workspace = true }
2 changes: 1 addition & 1 deletion dnas/demo/zomes/integrity/demo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "prefix_index"
version = "0.8.0"
name = "hc_prefix_index"
version = "0.9.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]
name = "prefix_index"
name = "hc_prefix_index"

[dependencies]
hdk = { workspace = true }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//use crate::PREFIX_INDEX_WIDTH;
use crate::PrefixIndex;
use hdk::hash_path::path::{root_hash, Component};
use hdk::prelude::*;
Expand Down

0 comments on commit c8bd3cc

Please sign in to comment.