pub struct LearningStore;Expand description
Round-trip serialisation helper for LearningEngine.
Implementations§
Source§impl LearningStore
impl LearningStore
Sourcepub fn save(engine: &LearningEngine, path: &Path) -> Result<()>
pub fn save(engine: &LearningEngine, path: &Path) -> Result<()>
Serialises engine to a JSON file at path.
Creates the file (and all parent directories) if they do not exist.
§Errors
Returns an error if serialisation fails or the file cannot be created.
§Examples
use lmm_agent::cognition::learning::store::LearningStore;
use lmm_agent::cognition::learning::engine::LearningEngine;
use lmm_agent::cognition::learning::config::LearningConfig;
let engine = LearningEngine::new(LearningConfig::default());
let path = std::env::temp_dir().join(format!("helm_doctest_{}.json", uuid::Uuid::new_v4()));
LearningStore::save(&engine, &path).unwrap();Sourcepub fn load(path: &Path) -> Result<LearningEngine>
pub fn load(path: &Path) -> Result<LearningEngine>
Deserialises a LearningEngine from the JSON file at path.
§Errors
Returns an error if the file cannot be read or if the JSON is malformed.
§Examples
use lmm_agent::cognition::learning::store::LearningStore;
use lmm_agent::cognition::learning::engine::LearningEngine;
use lmm_agent::cognition::learning::config::LearningConfig;
let engine = LearningEngine::new(LearningConfig::default());
let path = std::env::temp_dir().join(format!("helm_load_doctest_{}.json", uuid::Uuid::new_v4()));
LearningStore::save(&engine, &path).unwrap();
let loaded = LearningStore::load(&path).unwrap();
assert_eq!(loaded.config().alpha, engine.config().alpha);Auto Trait Implementations§
impl Freeze for LearningStore
impl RefUnwindSafe for LearningStore
impl Send for LearningStore
impl Sync for LearningStore
impl Unpin for LearningStore
impl UnsafeUnpin for LearningStore
impl UnwindSafe for LearningStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more