feat: add flush bucket and flush object commands
BREAKING CHANGES: push, query and suggestion commands with optional variables now haven't option arguments in methods
This commit is contained in:
parent
b73bddf7fc
commit
54e82f78d7
2 changed files with 19 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sonic-channel"
|
name = "sonic-channel"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
|
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
|
||||||
description = "Rust client for sonic search backend"
|
description = "Rust client for sonic search backend"
|
||||||
categories = ["api-bindings"]
|
categories = ["api-bindings"]
|
||||||
|
@ -16,13 +16,13 @@ readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
regex = "1.3.4"
|
regex = { version = "1.3.4", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["search"]
|
default = ["search"]
|
||||||
|
|
||||||
ingest = []
|
ingest = ["regex"]
|
||||||
search = []
|
search = ["regex"]
|
||||||
control = []
|
control = []
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,22 +14,27 @@ macro_rules! init_commands {
|
||||||
$(
|
$(
|
||||||
use $cmd_name:ident
|
use $cmd_name:ident
|
||||||
for fn $fn_name:ident
|
for fn $fn_name:ident
|
||||||
$(<$($lt:lifetime)+>)?
|
$(<$($lt:lifetime)+>)? (
|
||||||
($($args:tt)*)
|
$($args:tt)*
|
||||||
;
|
);
|
||||||
)*
|
)*
|
||||||
) => {
|
) => {
|
||||||
$(init_commands!(use $cmd_name for fn $fn_name $(<$($lt)+>)? ($($args)*));)*
|
$(init_commands!(use $cmd_name for fn $fn_name $(<$($lt)+>)? ($($args)*));)*
|
||||||
};
|
};
|
||||||
|
|
||||||
(use $cmd_name:ident for fn $fn_name:ident $(<$($lt:lifetime)+>)? ($($arg_name:ident : $arg_type:ty,)*)) => {
|
(
|
||||||
|
use $cmd_name:ident
|
||||||
|
for fn $fn_name:ident $(<$($lt:lifetime)+>)? (
|
||||||
|
$($arg_name:ident : $arg_type:ty $( => $arg_value:expr)?,)*
|
||||||
|
)
|
||||||
|
) => {
|
||||||
pub fn $fn_name $(<$($lt)+>)? (
|
pub fn $fn_name $(<$($lt)+>)? (
|
||||||
&self,
|
&self,
|
||||||
$($arg_name: $arg_type),*
|
$($arg_name: $arg_type),*
|
||||||
) -> crate::result::Result<
|
) -> crate::result::Result<
|
||||||
<$cmd_name as crate::commands::StreamCommand>::Response,
|
<$cmd_name as crate::commands::StreamCommand>::Response,
|
||||||
> {
|
> {
|
||||||
let command = $cmd_name { $($arg_name,)* ..Default::default() };
|
let command = $cmd_name { $($arg_name $(: $arg_value)?,)* ..Default::default() };
|
||||||
self.run_command(command)
|
self.run_command(command)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -178,7 +183,7 @@ impl SonicChannel {
|
||||||
bucket: &'a str,
|
bucket: &'a str,
|
||||||
object: &'a str,
|
object: &'a str,
|
||||||
text: &'a str,
|
text: &'a str,
|
||||||
locale: Option<&'a str>,
|
locale: &'a str => Some(locale),
|
||||||
);
|
);
|
||||||
|
|
||||||
use FlushCommand for fn flushc<'a>(
|
use FlushCommand for fn flushc<'a>(
|
||||||
|
@ -198,15 +203,15 @@ impl SonicChannel {
|
||||||
collection: &'a str,
|
collection: &'a str,
|
||||||
bucket: &'a str,
|
bucket: &'a str,
|
||||||
terms: &'a str,
|
terms: &'a str,
|
||||||
limit: Option<usize>,
|
limit: usize => Some(limit),
|
||||||
);
|
);
|
||||||
|
|
||||||
use QueryCommand for fn query_with_limit_and_offset<'a>(
|
use QueryCommand for fn query_with_limit_and_offset<'a>(
|
||||||
collection: &'a str,
|
collection: &'a str,
|
||||||
bucket: &'a str,
|
bucket: &'a str,
|
||||||
terms: &'a str,
|
terms: &'a str,
|
||||||
limit: Option<usize>,
|
limit: usize => Some(limit),
|
||||||
offset: Option<usize>,
|
offset: usize => Some(limit),
|
||||||
);
|
);
|
||||||
|
|
||||||
use SuggestCommand for fn suggest<'a>(
|
use SuggestCommand for fn suggest<'a>(
|
||||||
|
@ -219,7 +224,7 @@ impl SonicChannel {
|
||||||
collection: &'a str,
|
collection: &'a str,
|
||||||
bucket: &'a str,
|
bucket: &'a str,
|
||||||
word: &'a str,
|
word: &'a str,
|
||||||
limit: Option<usize>,
|
limit: usize => Some(limit),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue