sonic-channel/README.md

69 lines
1.3 KiB
Markdown
Raw Normal View History

2020-07-18 11:01:51 +03:00
# Sonic Channel
Rust client for [sonic] search backend.
We recommend you start with the [documentation].
## Installation
Add `sonic-channel = { version = "0.1" }` as a dependency in `Cargo.toml`.
`Cargo.toml` example:
```toml
[package]
name = "my-crate"
version = "0.1.0"
authors = ["Me <user@rust-lang.org>"]
[dependencies]
sonic-channel = { version = "0.1" }
```
## Example usage
2020-07-18 11:36:31 +03:00
### Search channel
2020-07-18 11:01:51 +03:00
```rust
2020-07-18 11:36:31 +03:00
use sonic_channel::*;
fn main() -> Result<(), SonicError> {
let mut channel = SonicChannel::connect("localhost:1491")?;
channel.start(ChannelMode::Search, "SecretPassword")?;
let objects = channel.query("collection", "bucket", "recipe")?;
dbg!(objects);
2020-07-18 11:01:51 +03:00
2020-07-18 11:36:31 +03:00
Ok(())
2020-07-18 11:01:51 +03:00
}
```
2020-07-18 11:36:31 +03:00
### Ingest channel
2020-07-18 11:01:51 +03:00
```rust
2020-07-18 11:36:31 +03:00
use sonic_channel::*;
fn main() -> Result<(), SonicError> {
let mut channel = SonicChannel::connect("localhost:1491")?;
channel.start(ChannelMode::Ingest, "SecretPassword")?;
let pushed = channel.push("collection", "bucket", "user:1", "my best recipe")?;
dbg!(pushed);
Ok(())
2020-07-18 11:01:51 +03:00
}
```
## Available features
* **default** - ["search"]
* **search** - Add sonic search mode with methods
* **ignite** - Add sonic ignite mode with methods
* **control** - Add sonic control mode with methods
[sonic]: https://github.com/valeriansaliou/sonic
[documentation]: https://docs.rs/sonic-channel