|
17 | 17 |
|
18 | 18 | //! # Actions |
19 | 19 | //! |
20 | | -//! This module contains macros and other methods for running actions. To run actions: |
| 20 | +//! This module contains traits for running actions. To run actions: |
21 | 21 | //! - For the `sync` feature, add this import: |
22 | 22 | //! ``` |
23 | 23 | //! use skytable::actions::Actions; |
@@ -50,7 +50,9 @@ use crate::Response; |
50 | 50 | use core::{future::Future, pin::Pin}; |
51 | 51 | use std::io::ErrorKind; |
52 | 52 |
|
| 53 | +/// The error string returned when the snapshot engine is busy |
53 | 54 | pub const ERR_SNAPSHOT_BUSY: &str = "err-snapshot-busy"; |
| 55 | +/// The error string returned when periodic snapshots are busy |
54 | 56 | pub const ERR_SNAPSHOT_DISABLED: &str = "err-snapshot-disabled"; |
55 | 57 |
|
56 | 58 | /// Errors while running actions |
@@ -152,26 +154,26 @@ impl<T> AsyncActions for T where T: AsyncSocket {} |
152 | 154 | implement_actions!( |
153 | 155 | /// Get the number of keys present in the database |
154 | 156 | fn dbsize() -> usize { |
155 | | - {Query::from("dbsize")} |
| 157 | + { Query::from("dbsize") } |
156 | 158 | Response::Item(Element::UnsignedInt(int)) => int as usize |
157 | 159 | } |
158 | 160 | /// Deletes a single or a number of keys |
159 | 161 | /// |
160 | 162 | /// This will return the number of keys that were deleted |
161 | | - fn del<T: IntoSkyhashBytes>(key: impl IntoSkyhashAction + 's) -> usize { |
162 | | - {Query::from("del").arg(key)} |
| 163 | + fn del(key: impl IntoSkyhashAction + 's) -> usize { |
| 164 | + { Query::from("del").arg(key) } |
163 | 165 | Response::Item(Element::UnsignedInt(int)) => int as usize |
164 | 166 | } |
165 | 167 | /// Checks if a key (or keys) exist(s) |
166 | 168 | /// |
167 | 169 | /// This will return the number of keys that do exist |
168 | | - fn exists<T: IntoSkyhashBytes>(key: impl IntoSkyhashAction + 's) -> usize { |
169 | | - {Query::from("exists").arg(key)} |
| 170 | + fn exists(key: impl IntoSkyhashAction + 's) -> usize { |
| 171 | + { Query::from("exists").arg(key) } |
170 | 172 | Response::Item(Element::UnsignedInt(int)) => int as usize |
171 | 173 | } |
172 | 174 | /// Removes all the keys present in the database |
173 | 175 | fn flushdb() -> () { |
174 | | - {Query::from("flushdb")} |
| 176 | + { Query::from("flushdb") } |
175 | 177 | Response::Item(Element::RespCode(RespCode::Okay)) => {} |
176 | 178 | } |
177 | 179 | /// Get the value of a key |
@@ -247,7 +249,7 @@ implement_actions!( |
247 | 249 | } |
248 | 250 | /// Deletes all the provided keys if they exist or doesn't do anything at all. This method |
249 | 251 | /// will return true if all the provided keys were deleted, else it will return false |
250 | | - fn sdel<T: IntoSkyhashBytes>(keys: impl IntoSkyhashAction + 's) -> bool { |
| 252 | + fn sdel(keys: impl IntoSkyhashAction + 's) -> bool { |
251 | 253 | { Query::from("sdel").arg(keys) } |
252 | 254 | Response::Item(Element::RespCode(RespCode::Okay)) => true, |
253 | 255 | Response::Item(Element::RespCode(RespCode::NotFound)) => false |
|
0 commit comments