mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 15:19:58 -07:00
general: add /api/last route
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
pub trait AnyMap {
|
||||
fn path(&self) -> &Path;
|
||||
fn path_last(&self) -> &Option<PathBuf>;
|
||||
|
||||
fn last_value(&self) -> Option<Value>;
|
||||
|
||||
fn t_name(&self) -> &str;
|
||||
|
||||
fn exported_path_with_t_name(&self) -> Vec<(&Path, &str)> {
|
||||
@@ -16,8 +20,6 @@ pub trait AnyMap {
|
||||
}
|
||||
}
|
||||
|
||||
// fn reset(&mut self) -> color_eyre::Result<()>;
|
||||
|
||||
fn pre_export(&mut self);
|
||||
fn export(&self) -> color_eyre::Result<()>;
|
||||
fn post_export(&mut self);
|
||||
|
||||
@@ -286,6 +286,13 @@ where
|
||||
&self.path_last
|
||||
}
|
||||
|
||||
fn last_value(&self) -> Option<serde_json::Value> {
|
||||
self.imported
|
||||
.last_key_value()
|
||||
.and_then(|(_, serialized)| serialized.last())
|
||||
.and_then(|v| serde_json::to_value(v).ok())
|
||||
}
|
||||
|
||||
fn t_name(&self) -> &str {
|
||||
std::any::type_name::<Value>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user