pub struct Blackboard {
pub entries: HashMap<String, BlackboardEntry>,
pub current_time: f64,
}Expand description
A typed, expiring key-value knowledge base for AI agents.
Fields§
§entries: HashMap<String, BlackboardEntry>§current_time: f64Implementations§
Source§impl Blackboard
impl Blackboard
pub fn new() -> Self
Sourcepub fn set(&mut self, key: impl Into<String>, value: impl Into<BlackboardValue>)
pub fn set(&mut self, key: impl Into<String>, value: impl Into<BlackboardValue>)
Store a permanent entry.
Sourcepub fn set_with_ttl(
&mut self,
key: impl Into<String>,
value: impl Into<BlackboardValue>,
ttl: f64,
)
pub fn set_with_ttl( &mut self, key: impl Into<String>, value: impl Into<BlackboardValue>, ttl: f64, )
Store an entry that expires after ttl seconds.
Sourcepub fn get(&self, key: &str) -> Option<&BlackboardValue>
pub fn get(&self, key: &str) -> Option<&BlackboardValue>
Retrieve a value if it exists and has not expired.
Sourcepub fn get_entry(&self, key: &str) -> Option<&BlackboardEntry>
pub fn get_entry(&self, key: &str) -> Option<&BlackboardEntry>
Retrieve the full entry (value + metadata).
pub fn get_bool(&self, key: &str) -> Option<bool>
pub fn get_int(&self, key: &str) -> Option<i64>
pub fn get_float(&self, key: &str) -> Option<f64>
pub fn get_vec2(&self, key: &str) -> Option<Vec2>
pub fn get_vec3(&self, key: &str) -> Option<Vec3>
pub fn get_str(&self, key: &str) -> Option<&str>
pub fn get_entity(&self, key: &str) -> Option<u64>
Sourcepub fn remove(&mut self, key: &str) -> Option<BlackboardValue>
pub fn remove(&mut self, key: &str) -> Option<BlackboardValue>
Remove a key from the blackboard.
pub fn contains(&self, key: &str) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn merge(&mut self, other: &Blackboard)
pub fn merge(&mut self, other: &Blackboard)
Merge entries from other into this blackboard.
Entries in other overwrite entries in self if the key already exists.
Sourcepub fn increment_int(&mut self, key: &str, delta: i64)
pub fn increment_int(&mut self, key: &str, delta: i64)
Increment an integer value, inserting 0 + delta if not present.
Sourcepub fn increment_float(&mut self, key: &str, delta: f64)
pub fn increment_float(&mut self, key: &str, delta: f64)
Increment a float value.
Sourcepub fn push_to_list(&mut self, key: &str, value: BlackboardValue)
pub fn push_to_list(&mut self, key: &str, value: BlackboardValue)
Append a value to a list entry; creates the list if not present.
Sourcepub fn snapshot(&self) -> Vec<(&String, &BlackboardValue)>
pub fn snapshot(&self) -> Vec<(&String, &BlackboardValue)>
Returns all non-expired (key, value) pairs.
Source§impl Blackboard
impl Blackboard
Sourcepub fn debug_dump(&self) -> String
pub fn debug_dump(&self) -> String
Dump all non-expired entries to a human-readable string.
Trait Implementations§
Source§impl Clone for Blackboard
impl Clone for Blackboard
Source§impl Debug for Blackboard
impl Debug for Blackboard
Auto Trait Implementations§
impl Freeze for Blackboard
impl RefUnwindSafe for Blackboard
impl Send for Blackboard
impl Sync for Blackboard
impl Unpin for Blackboard
impl UnsafeUnpin for Blackboard
impl UnwindSafe for Blackboard
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.