diff options
| author | Yigit Sever | 2021-05-10 21:06:43 +0300 |
|---|---|---|
| committer | Yigit Sever | 2021-05-10 21:06:43 +0300 |
| commit | e19cbb8be108c85629997791a5a6a117c51dcc37 (patch) | |
| tree | f362303bfd461771c26debe4badd501689dae090 | |
| parent | 953fcf7c0d829a7664c06a75bbd29987afe7b654 (diff) | |
| download | gradecoin-e19cbb8be108c85629997791a5a6a117c51dcc37.tar.gz gradecoin-e19cbb8be108c85629997791a5a6a117c51dcc37.tar.bz2 gradecoin-e19cbb8be108c85629997791a5a6a117c51dcc37.zip | |
Remove unused code
| -rw-r--r-- | src/validators.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/validators.rs b/src/validators.rs deleted file mode 100644 index 31344d8..0000000 --- a/src/validators.rs +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 1 | /// Custom validators incoming data | ||
| 2 | |||
| 3 | use log::error; | ||
| 4 | use serde::de::{Deserializer, Error as DeserializerError, Unexpected}; | ||
| 5 | use serde::ser::{Error as SerializerError, Serializer}; | ||
| 6 | use serde::Deserialize; | ||
| 7 | |||
| 8 | pub mod validate_block { | ||
| 9 | use super::*; | ||
| 10 | |||
| 11 | const ERROR_MESSAGE: &str = "block cannot have an empty transaction list"; | ||
| 12 | |||
| 13 | pub fn deserialize<'de, D>(deserializer: D) -> Result<u8, D::Error> | ||
| 14 | where | ||
| 15 | D: Deserializer<'de>, | ||
| 16 | { | ||
| 17 | let value = u8::deserialize(deserializer)?; | ||
| 18 | |||
| 19 | if value > 100 { | ||
| 20 | error!("{}", ERROR_MESSAGE); | ||
| 21 | |||
| 22 | return Err(DeserializerError::invalid_value( | ||
| 23 | Unexpected::Unsigned(u64::from(value)), | ||
| 24 | &ERROR_MESSAGE, | ||
| 25 | )); | ||
| 26 | } | ||
| 27 | |||
| 28 | Ok(value) | ||
| 29 | } | ||
| 30 | |||
| 31 | #[allow(clippy::trivially_copy_pass_by_ref)] | ||
| 32 | pub fn serialize<S>(value: &u8, serializer: S) -> Result<S::Ok, S::Error> | ||
| 33 | where | ||
| 34 | S: Serializer, | ||
| 35 | { | ||
| 36 | if *value > 100 { | ||
| 37 | error!("{}", ERROR_MESSAGE); | ||
| 38 | |||
| 39 | return Err(SerializerError::custom(ERROR_MESSAGE)); | ||
| 40 | } | ||
| 41 | |||
| 42 | serializer.serialize_u8(*value) | ||
| 43 | } | ||
| 44 | } | ||
