sonic_channel/lib.rs
1//! # Sonic Channel
2//! Rust client for [sonic] search backend.
3//!
4//!
5//! ## Example usage
6//!
7//! ### Search channel
8//!
9//! Note: This example requires enabling the `search` feature, enabled by default.
10//!
11//! ```rust,no_run
12//! use sonic_channel::*;
13//!
14//! fn main() -> result::Result<()> {
15//! let channel = SearchChannel::start(
16//! "localhost:1491",
17//! "SecretPassword",
18//! )?;
19//!
20//! let objects = channel.query(QueryRequest::new(
21//! Dest::col_buc("collection", "bucket"),
22//! "recipe",
23//! ))?;
24//! dbg!(objects);
25//!
26//! Ok(())
27//! }
28//! ```
29//!
30//! ### Ingest channel
31//!
32//! Note: This example requires enabling the `ingest` feature.
33//!
34//! ```rust,no_run
35//! use sonic_channel::*;
36//!
37//! fn main() -> result::Result<()> {
38//! let channel = IngestChannel::start(
39//! "localhost:1491",
40//! "SecretPassword",
41//! )?;
42//!
43//! let dest = Dest::col_buc("collection", "bucket").obj("object:1");
44//! let pushed = channel.push(PushRequest::new(dest, "my best recipe"))?;
45//! // or
46//! // let pushed = channel.push(
47//! // PushRequest::new(dest, "Мой лучший рецепт").lang(Lang::Rus)
48//! // )?;
49//! dbg!(pushed);
50//!
51//! Ok(())
52//! }
53//! ```
54//!
55//! ### Control channel
56//!
57//! Note: This example requires enabling the `control` feature.
58//!
59//! ```rust,no_run
60//! use sonic_channel::*;
61//!
62//! fn main() -> result::Result<()> {
63//! let channel = ControlChannel::start(
64//! "localhost:1491",
65//! "SecretPassword",
66//! )?;
67//!
68//! let result = channel.consolidate()?;
69//! assert_eq!(result, ());
70//!
71//! Ok(())
72//! }
73//! ```
74//!
75//! [sonic]: https://github.com/valeriansaliou/sonic
76
77// Rustc lints.
78#![deny(
79 missing_debug_implementations,
80 unsafe_code,
81 unstable_features,
82 unused_imports,
83 unused_qualifications
84)]
85#![warn(missing_docs)]
86// Clippy lints
87#![deny(clippy::all)]
88
89#[cfg(not(any(feature = "ingest", feature = "search", feature = "control")))]
90compile_error!(
91 r#"Either features "ingest" or "search" or "control" must be enabled for "sonic-channel" crate"#
92);
93
94#[macro_use]
95mod macroses;
96mod misc;
97
98pub(crate) mod protocol;
99
100mod channels;
101
102/// Contains the request parameters for each command to the sonic server.
103pub mod commands;
104
105/// Contains sonic channel error type and custom Result type for easy configure your functions.
106pub mod result;
107
108pub use channels::*;
109pub use commands::*;
110pub use misc::*;
111
112pub use whatlang::Lang;