mirror of
https://github.com/fluencelabs/fluent-pad
synced 2025-04-24 16:32:13 +00:00
Entry -> HistoryEntry
This commit is contained in:
parent
cc7ef8b24e
commit
ec2409648f
@ -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"
|
||||
|
@ -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<Result<()>> for EmptyResult {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<Vec<Entry>>> for GetEntriesServiceResult {
|
||||
fn from(result: Result<Vec<Entry>>) -> Self {
|
||||
impl From<Result<Vec<HistoryEntry>>> for GetEntriesServiceResult {
|
||||
fn from(result: Result<Vec<HistoryEntry>>) -> Self {
|
||||
match result {
|
||||
Ok(entries) => Self {
|
||||
ret_code: crate::service_api::SUCCESS_CODE,
|
||||
|
@ -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,
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mod entry;
|
||||
mod history_entry;
|
||||
mod errors;
|
||||
mod results;
|
||||
mod service_api;
|
||||
|
@ -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<Entry>,
|
||||
pub entries: Vec<HistoryEntry>,
|
||||
}
|
||||
|
||||
#[fce]
|
||||
|
@ -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<Vec<Entry>> {
|
||||
fn get_all_impl(auth: bool) -> Result<Vec<HistoryEntry>> {
|
||||
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<Vec<Entry>> {
|
||||
fn get_last_impl(last: u64, auth: bool) -> Result<Vec<HistoryEntry>> {
|
||||
is_authenticated(auth, 1)?;
|
||||
get_entries_with_limit(last)
|
||||
}
|
||||
|
@ -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<Entry>,
|
||||
entries: Vec<HistoryEntry>,
|
||||
tetraplet: Option<Tetraplet>,
|
||||
}
|
||||
|
||||
@ -46,16 +46,16 @@ pub fn add_entry(entry: String) -> Result<u64> {
|
||||
|
||||
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<Vec<Entry>> {
|
||||
pub fn get_entries_with_limit(limit: u64) -> Result<Vec<HistoryEntry>> {
|
||||
let data = get_data().lock();
|
||||
let limit = u64_to_usize(limit)?;
|
||||
|
||||
let entries: Vec<Entry> = data
|
||||
let entries: Vec<HistoryEntry> = data
|
||||
.entries
|
||||
.to_vec()
|
||||
.iter()
|
||||
@ -67,7 +67,7 @@ pub fn get_entries_with_limit(limit: u64) -> Result<Vec<Entry>> {
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
pub fn get_all_entries() -> Result<Vec<Entry>> {
|
||||
pub fn get_all_entries() -> Result<Vec<HistoryEntry>> {
|
||||
let data = get_data().lock();
|
||||
|
||||
Ok(data.entries.to_vec())
|
||||
|
Loading…
x
Reference in New Issue
Block a user