Crate sonic_channel
source · [−]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
Contains the request parameters for each command to the sonic server.
Contains sonic channel error type and custom Result type for easy configure your functions.
Structs
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.
Search objects destination. Contains collection and bucket.
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.
Search data destination. Contains collection, bucket and object.
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.
Root and Heart of this library.
Enums
Channel modes supported by sonic search backend.
Traits
This trait should be implemented for all supported sonic channels