pub fn import_with_handler<I, H>(
persy: &Persy,
importer: I,
handler: H,
) -> EIRes<()>Expand description
Import the data to a persy storage from a custom format
ยงExample
use persy::{Persy, Config};
use persy_expimp::{import_with_handler,Info, Handler, Mapper};
struct HandlerImpl{ //...
};
impl Handler for HandlerImpl {
fn pre(&self, _persy: &Persy, _mapper: &Mapper) -> EIRes<()> {
//....
Ok(())
}
fn post(&self, _persy: &Persy, _mapper: &Mapper) -> EIRes<()> {
//....
Ok(())
}
}
Persy::create("imported.persy")?;
let persy = Persy::open("imported.persy", Config::new())?;
// Source informations from a custom source
let source = Vec::<Info>::new();
import_with_handler(&persy,source.into_iter(), HandlerImpl{})?;