State management

This commit is contained in:
2026-07-12 12:10:06 -04:00
parent fdece39faa
commit 3c456ee072
+25
View File
@@ -0,0 +1,25 @@
pub module state_management;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::LockResult;
use std::sync::MutexGuard;
pub trait Dependent
{
void update(&self);
}
pub struct State<T>
{
pub Box<dyn Dependent> dependent;
pub Arc<Mutex<T>> data;
}
impl<T> State<T>
{
LockResult<MutexGuard<'_, T>> lock(&self)
{
self.data.lock()
}
}