chore: add rustc lints
This commit is contained in:
parent
e3b5f90893
commit
3e36f9b3ef
2 changed files with 60 additions and 3 deletions
|
@ -31,8 +31,8 @@ macro_rules! init_commands {
|
|||
pub fn $fn_name $(<$($lt)+>)? (
|
||||
&self,
|
||||
$($arg_name: $arg_type),*
|
||||
) -> crate::result::Result<
|
||||
<$cmd_name as crate::commands::StreamCommand>::Response,
|
||||
) -> $crate::result::Result<
|
||||
<$cmd_name as $crate::commands::StreamCommand>::Response,
|
||||
> {
|
||||
let command = $cmd_name { $($arg_name $(: $arg_value)?,)* ..Default::default() };
|
||||
self.run_command(command)
|
||||
|
@ -107,7 +107,7 @@ impl SonicChannel {
|
|||
Ok(message)
|
||||
}
|
||||
|
||||
pub fn run_command<SC: StreamCommand>(&self, command: SC) -> Result<SC::Response> {
|
||||
fn run_command<SC: StreamCommand>(&self, command: SC) -> Result<SC::Response> {
|
||||
self.write(&command)?;
|
||||
let message = self.read(SC::READ_LINES_COUNT)?;
|
||||
command.receive(message)
|
||||
|
|
57
src/lib.rs
57
src/lib.rs
|
@ -1,4 +1,61 @@
|
|||
//! # Sonic Channel
|
||||
//! Rust client for [sonic] search backend.
|
||||
//!
|
||||
//!
|
||||
//! ## Example usage
|
||||
//!
|
||||
//! ### Search channel
|
||||
//!
|
||||
//! ```rust
|
||||
//! use sonic_channel::*;
|
||||
//!
|
||||
//! fn main() -> result::Result<()> {
|
||||
//! let channel = SonicChannel::connect_with_start(
|
||||
//! ChannelMode::Search,
|
||||
//! "localhost:1491",
|
||||
//! "SecretPassword",
|
||||
//! )?;
|
||||
//!
|
||||
//! let objects = channel.query("collection", "bucket", "recipe")?;
|
||||
//! dbg!(objects);
|
||||
//!
|
||||
//! Ok(())
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! ### Ingest channel
|
||||
//!
|
||||
//! ```rust
|
||||
//! use sonic_channel::*;
|
||||
//!
|
||||
//! fn main() -> result::Result<()> {
|
||||
//! let mut channel = SonicChannel::connect_with_start(
|
||||
//! ChannelMode::Ingest,
|
||||
//! "localhost:1491",
|
||||
//! "SecretPassword",
|
||||
//! )?;
|
||||
//!
|
||||
//! let pushed = channel.push("collection", "bucket", "object:1", "my best recipe")?;
|
||||
//! // or
|
||||
//! // let pushed = channel.push_with_locale("collection", "bucket", "object:1", "Мой лучший рецепт", "rus")?;
|
||||
//! dbg!(pushed);
|
||||
//!
|
||||
//! Ok(())
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! [sonic]: https://github.com/valeriansaliou/sonic
|
||||
|
||||
// Rustc lints.
|
||||
#![allow(dead_code)]
|
||||
#![deny(
|
||||
missing_debug_implementations,
|
||||
unsafe_code,
|
||||
unstable_features,
|
||||
unused_imports,
|
||||
unused_qualifications
|
||||
)]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
#[cfg(not(any(feature = "ingest", feature = "search", feature = "control")))]
|
||||
compile_error!(r#"Either features "ingest" or "search" or "control" must be enabled for "sonic-channel" crate"#);
|
||||
|
|
Loading…
Reference in a new issue