Expand description
§Sonic Channel
Rust client for sonic search backend.
§Example usage
§Search channel
Note: This example requires enabling the search feature, enabled by default.
use sonic_channel::*;
fn main() -> result::Result<()> {
let channel = SearchChannel::start(
"localhost:1491",
"SecretPassword",
)?;
let objects = channel.query(QueryRequest::new(
Dest::col_buc("collection", "bucket"),
"recipe",
))?;
dbg!(objects);
Ok(())
}§Ingest channel
Note: This example requires enabling the ingest feature.
use sonic_channel::*;
fn main() -> result::Result<()> {
let channel = IngestChannel::start(
"localhost:1491",
"SecretPassword",
)?;
let dest = Dest::col_buc("collection", "bucket").obj("object:1");
let pushed = channel.push(PushRequest::new(dest, "my best recipe"))?;
// or
// let pushed = channel.push(
// PushRequest::new(dest, "Мой лучший рецепт").lang(Lang::Rus)
// )?;
dbg!(pushed);
Ok(())
}§Control channel
Note: This example requires enabling the control feature.
use sonic_channel::*;
fn main() -> result::Result<()> {
let channel = ControlChannel::start(
"localhost:1491",
"SecretPassword",
)?;
let result = channel.consolidate()?;
assert_eq!(result, ());
Ok(())
}Re-exports§
pub use commands::*;
Modules§
- commands
- Contains the request parameters for each command to the sonic server.
- result
- Contains sonic channel error type and custom Result type for easy configure your functions.
Structs§
- Control
Channel - The Sonic Channel Control mode is used for administration purposes. Once in this mode, you cannot switch to other modes or gain access to commands from other modes.
- Dest
- Search objects destination. Contains collection and bucket.
- Ingest
Channel - The Sonic Channel Ingest mode is used for altering the search index (push, pop and flush). Once in this mode, you cannot switch to other modes or gain access to commands from other modes.
- ObjDest
- Search data destination. Contains collection, bucket and object.
- Search
Channel - The Sonic Channel Search mode is used for querying the search index. Once in this mode, you cannot switch to other modes or gain access to commands from other modes.
- Sonic
Stream - Root and Heart of this library.
Enums§
- Channel
Mode - Channel modes supported by sonic search backend.
- Lang
- Represents a language following ISO 639-3 standard.
Traits§
- Sonic
Channel - This trait should be implemented for all supported sonic channels