doc: add feature info to examples

Closes #1
This commit is contained in:
Dmitriy Pleshevskiy 2020-07-31 23:34:58 +03:00
parent 04f52bb076
commit 94b1d398ac
3 changed files with 24 additions and 4 deletions

View file

@ -26,6 +26,8 @@ sonic-channel = { version = "0.2" }
### Search channel ### Search channel
Note: This example requires enabling the `search` feature, enabled by default.
```rust ```rust
use sonic_channel::*; use sonic_channel::*;
@ -45,6 +47,8 @@ fn main() -> result::Result<()> {
### Ingest channel ### Ingest channel
Note: This example requires enabling the `ingest` feature.
```rust ```rust
use sonic_channel::*; use sonic_channel::*;

View file

@ -7,7 +7,6 @@ use std::net::{TcpStream, ToSocketAddrs};
const DEFAULT_SONIC_PROTOCOL_VERSION: usize = 1; const DEFAULT_SONIC_PROTOCOL_VERSION: usize = 1;
const MAX_LINE_BUFFER_SIZE: usize = 20000; const MAX_LINE_BUFFER_SIZE: usize = 20000;
const UNINITIALIZED_MODE_MAX_BUFFER_SIZE: usize = 200; const UNINITIALIZED_MODE_MAX_BUFFER_SIZE: usize = 200;
const BUFFER_LINE_SEPARATOR: u8 = '\n' as u8;
macro_rules! init_commands { macro_rules! init_commands {
( (
@ -54,15 +53,28 @@ macro_rules! init_commands {
/// Channel modes supported by sonic search backend. /// Channel modes supported by sonic search backend.
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub enum ChannelMode { pub enum ChannelMode {
/// Search mode /// Sonic server search channel mode.
///
/// In this mode you can use `query`, `suggest`, `ping` and `quit` commands.
///
/// Note: This mode requires enabling the `search` feature.
#[cfg(feature = "search")] #[cfg(feature = "search")]
Search, Search,
/// Ingest mode /// Sonic server ingest channel mode.
///
/// In this mode you can use `push`, `pop`, `flushc`, `flushb`, `flusho`,
/// `ping` and `quit` commands.
///
/// Note: This mode requires enabling the `ingest` feature.
#[cfg(feature = "ingest")] #[cfg(feature = "ingest")]
Ingest, Ingest,
/// Control mode /// Sonic server control channel mode.
///
/// In this mode you can use `ping` and `quit` commands.
///
/// Note: This mode requires enabling the `control` feature.
#[cfg(feature = "control")] #[cfg(feature = "control")]
Control, Control,
} }

View file

@ -5,6 +5,8 @@
//! ## Example usage //! ## Example usage
//! //!
//! ### Search channel //! ### Search channel
//!
//! Note: This example requires enabling the `search` feature, enabled by default.
//! //!
//! ```rust //! ```rust
//! use sonic_channel::*; //! use sonic_channel::*;
@ -25,6 +27,8 @@
//! //!
//! ### Ingest channel //! ### Ingest channel
//! //!
//! Note: This example requires enabling the `ingest` feature.
//!
//! ```rust //! ```rust
//! use sonic_channel::*; //! use sonic_channel::*;
//! //!