Crate sonic_channel

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§

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§

ControlChannel
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.
IngestChannel
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.
SearchChannel
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.
SonicStream
Root and Heart of this library.

Enums§

ChannelMode
Channel modes supported by sonic search backend.
Lang
Represents a language following ISO 639-3 standard.

Traits§

SonicChannel
This trait should be implemented for all supported sonic channels