exocore-core 0.1.26

Core of Exocore (Distributed applications framework)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::io::Result;

use serde::{de::DeserializeOwned, Serialize};

pub mod json_disk_store;

pub trait SimpleStore<T: Serialize + DeserializeOwned> {
    fn read(&self) -> Result<Option<T>>;
    fn write(&self, value: &T) -> Result<()>;

    fn read_or_default(&self) -> Result<T>
    where
        T: Default,
    {
        self.read().map(|v| v.unwrap_or_default())
    }
}