From ec2409648f2fc7827fbbcab56a7b682ff3a7ef47 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Thu, 14 Jan 2021 20:12:43 +0300 Subject: [PATCH] Entry -> HistoryEntry --- services/history-inmemory/Cargo.toml | 2 +- services/history-inmemory/src/errors.rs | 6 +++--- .../src/{entry.rs => history_entry.rs} | 2 +- services/history-inmemory/src/main.rs | 2 +- services/history-inmemory/src/results.rs | 4 ++-- services/history-inmemory/src/service_api.rs | 6 +++--- services/history-inmemory/src/storage_api.rs | 12 ++++++------ 7 files changed, 17 insertions(+), 17 deletions(-) rename services/history-inmemory/src/{entry.rs => history_entry.rs} (96%) diff --git a/services/history-inmemory/Cargo.toml b/services/history-inmemory/Cargo.toml index 01a2dca..d2cb27a 100644 --- a/services/history-inmemory/Cargo.toml +++ b/services/history-inmemory/Cargo.toml @@ -9,7 +9,7 @@ name = "history" path = "src/main.rs" [dependencies] -fluence = { version = "0.2.16", features = ["logger"] } +fluence = { version = "0.2.18", features = ["logger"] } anyhow = "1.0.31" boolinator = "2.4.0" diff --git a/services/history-inmemory/src/errors.rs b/services/history-inmemory/src/errors.rs index 726a411..9027d10 100644 --- a/services/history-inmemory/src/errors.rs +++ b/services/history-inmemory/src/errors.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use crate::entry::Entry; +use crate::history_entry::HistoryEntry; use crate::Result; use crate::results::{AddServiceResult, EmptyResult, GetEntriesServiceResult}; @@ -86,8 +86,8 @@ impl From> for EmptyResult { } } -impl From>> for GetEntriesServiceResult { - fn from(result: Result>) -> Self { +impl From>> for GetEntriesServiceResult { + fn from(result: Result>) -> Self { match result { Ok(entries) => Self { ret_code: crate::service_api::SUCCESS_CODE, diff --git a/services/history-inmemory/src/entry.rs b/services/history-inmemory/src/history_entry.rs similarity index 96% rename from services/history-inmemory/src/entry.rs rename to services/history-inmemory/src/history_entry.rs index a4c1906..477025e 100644 --- a/services/history-inmemory/src/entry.rs +++ b/services/history-inmemory/src/history_entry.rs @@ -18,7 +18,7 @@ use fluence::fce; #[fce] #[derive(Clone, Debug, Default, Eq, PartialEq, Hash)] -pub struct Entry { +pub struct HistoryEntry { pub id: u64, pub body: String, } diff --git a/services/history-inmemory/src/main.rs b/services/history-inmemory/src/main.rs index 39b350b..36df5e6 100644 --- a/services/history-inmemory/src/main.rs +++ b/services/history-inmemory/src/main.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -mod entry; +mod history_entry; mod errors; mod results; mod service_api; diff --git a/services/history-inmemory/src/results.rs b/services/history-inmemory/src/results.rs index 201707a..e15c7c8 100644 --- a/services/history-inmemory/src/results.rs +++ b/services/history-inmemory/src/results.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use crate::entry::Entry; +use crate::history_entry::HistoryEntry; use fluence::fce; #[fce] @@ -28,7 +28,7 @@ pub struct AddServiceResult { pub struct GetEntriesServiceResult { pub ret_code: i32, pub err_msg: String, - pub entries: Vec, + pub entries: Vec, } #[fce] diff --git a/services/history-inmemory/src/service_api.rs b/services/history-inmemory/src/service_api.rs index cd590ed..f0f4642 100644 --- a/services/history-inmemory/src/service_api.rs +++ b/services/history-inmemory/src/service_api.rs @@ -16,7 +16,7 @@ use crate::storage_api::*; -use crate::entry::Entry; +use crate::history_entry::HistoryEntry; use crate::results::{AddServiceResult, EmptyResult, GetEntriesServiceResult}; use crate::utils::u64_to_usize; use crate::Result; @@ -38,7 +38,7 @@ fn add(entry: String, auth: bool) -> AddServiceResult { // get all entries #[fce] fn get_all(auth: bool) -> GetEntriesServiceResult { - fn get_all_impl(auth: bool) -> Result> { + fn get_all_impl(auth: bool) -> Result> { is_authenticated(auth, 0)?; get_all_entries() } @@ -48,7 +48,7 @@ fn get_all(auth: bool) -> GetEntriesServiceResult { // get last entry #[fce] fn get_last(last: u64, auth: bool) -> GetEntriesServiceResult { - fn get_last_impl(last: u64, auth: bool) -> Result> { + fn get_last_impl(last: u64, auth: bool) -> Result> { is_authenticated(auth, 1)?; get_entries_with_limit(last) } diff --git a/services/history-inmemory/src/storage_api.rs b/services/history-inmemory/src/storage_api.rs index d15cb7e..ab924d9 100644 --- a/services/history-inmemory/src/storage_api.rs +++ b/services/history-inmemory/src/storage_api.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use crate::entry::Entry; +use crate::history_entry::HistoryEntry; use crate::Result; use crate::utils::{u64_to_usize, usize_to_u64}; @@ -31,7 +31,7 @@ pub struct Tetraplet { #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct Data { - entries: Vec, + entries: Vec, tetraplet: Option, } @@ -46,16 +46,16 @@ pub fn add_entry(entry: String) -> Result { let id = usize_to_u64(data.entries.len())?; - data.entries.push(Entry { id, body: entry }); + data.entries.push(HistoryEntry { id, body: entry }); return Ok(id); } -pub fn get_entries_with_limit(limit: u64) -> Result> { +pub fn get_entries_with_limit(limit: u64) -> Result> { let data = get_data().lock(); let limit = u64_to_usize(limit)?; - let entries: Vec = data + let entries: Vec = data .entries .to_vec() .iter() @@ -67,7 +67,7 @@ pub fn get_entries_with_limit(limit: u64) -> Result> { Ok(entries) } -pub fn get_all_entries() -> Result> { +pub fn get_all_entries() -> Result> { let data = get_data().lock(); Ok(data.entries.to_vec())