Skip to main content

PersistentColony

Struct PersistentColony 

Source
pub struct PersistentColony { /* private fields */ }
Expand description

A Colony with optional SQLite persistence.

Wraps a standard Colony and provides automatic loading/saving of the knowledge graph to SQLite.

Implementations§

Source§

impl PersistentColony

Source

pub fn colony(&self) -> &Colony

Get a reference to the inner colony.

Source

pub fn colony_mut(&mut self) -> &mut Colony

Get a mutable reference to the inner colony.

Source

pub fn into_inner(self) -> Colony

Consume self and return the inner colony.

Note: This will NOT trigger auto-save. Call save() first if needed.

Source

pub fn has_persistence(&self) -> bool

Check if persistence is enabled.

Source

pub fn save(&mut self) -> Result<(), BuilderError>

Source

pub fn persistence_path(&self) -> Option<&Path>

Source§

impl PersistentColony

Source

pub fn run(&mut self, ticks: u64) -> Vec<Vec<ColonyEvent>>

Run simulation for N ticks.

Source

pub fn tick(&mut self) -> Vec<ColonyEvent>

Run a single tick.

Source

pub fn ingest_document( &mut self, title: &str, content: &str, position: Position, ) -> DocumentId

Ingest a document.

Source

pub fn stats(&self) -> ColonyStats

Get colony statistics.

Source

pub fn snapshot(&self) -> ColonySnapshot

Get a snapshot of the colony.

Source

pub fn spawn( &mut self, agent: Box<dyn Agent<Input = String, Fragment = String, Presentation = Vec<String>>>, ) -> AgentId

Spawn an agent.

Source

pub fn alive_count(&self) -> usize

Number of alive agents.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.