Skip to main content

Chronicle

Struct Chronicle 

Source
pub struct Chronicle {
    pub graph: StableGraph<Entity, Relationship>,
    pub index: HashMap<String, NodeIndex>,
    pub config: ValidationConfig,
}
Expand description

The core chronicle graph.

Holds a heterogeneous StableGraph of Entity nodes connected by Relationship edges, plus a string-to-index lookup map and a ValidationConfig that governs policy decisions such as which statuses are considered terminal.

Construct via Chronicle::from_directory (default config) or Chronicle::from_directory_with_config (custom config). Both load every .ron file under the conventional subdirectory layout (actors/, places/, events/, concepts/, accounts/), insert nodes, and wire up edges in a single pass.

Fields§

§graph: StableGraph<Entity, Relationship>

The underlying directed graph. Nodes are Entity variants; edges are Relationship variants that encode the kind and, where applicable, the payload (role, sentiment, state-change) of each connection.

§index: HashMap<String, NodeIndex>

Maps every entity’s string id to its NodeIndex in the graph, providing O(1) lookup by id.

§config: ValidationConfig

Policy configuration used during validation — controls which Status values are treated as terminal (e.g. Dead, Destroyed).

Implementations§

Source§

impl Chronicle

Source

pub fn from_directory(path: &Path) -> Result<Self, ChronicleError>

Load all RON files from a directory, build the graph with default config.

Equivalent to calling from_directory_with_config with ValidationConfig::default().

§Errors

Returns ChronicleError on I/O failures, RON parse errors, or duplicate entity ids across files.

Source

pub fn from_directory_with_config( path: &Path, config: ValidationConfig, ) -> Result<Self, ChronicleError>

Load all RON files from a directory with a custom ValidationConfig.

Walks the conventional subdirectories (actors/, places/, events/, concepts/, accounts/), deserialises every .ron file into the corresponding entity type, inserts nodes, and then builds all edges in a separate pass via build_edges.

§Errors

Returns ChronicleError on I/O failures, RON parse errors, or duplicate entity ids.

Source

pub fn validate(&self) -> ValidationReport

Run all validation passes and return a ValidationReport.

The report aggregates referential-integrity, temporal-consistency, state-validity, and orphan-detection errors found in the graph.

Source

pub fn can_add_event(&self, event: &Event) -> Result<(), Vec<ValidationError>>

Check whether a proposed Event is consistent with the existing graph.

Returns Ok(()) if the event can be inserted without violating any temporal or state constraints. Returns Err with a list of ValidationErrors describing every conflict found.

Source§

impl Chronicle

Source

pub fn actor(&self, id: &str) -> Option<ActorQuery<'_>>

Look up an actor by id and return a query handle for it.

Returns None if the id does not exist or does not refer to an Actor.

Source

pub fn event(&self, id: &str) -> Option<EventQuery<'_>>

Look up an event by id and return a query handle for it.

Returns None if the id does not exist or does not refer to an Event.

Source

pub fn place(&self, id: &str) -> Option<PlaceQuery<'_>>

Look up a place by id and return a query handle for it.

Returns None if the id does not exist or does not refer to a Place.

Source

pub fn concept(&self, id: &str) -> Option<ConceptQuery<'_>>

Look up a concept by id and return a query handle for it.

Returns None if the id does not exist or does not refer to a Concept.

Source

pub fn mentions(&self, entity_id: &str) -> Vec<&Account>

All accounts whose text contains a {entity_id} reference to this entity.

Source

pub fn accounts_of(&self, event_id: &str) -> Vec<&Account>

All accounts that reference this event (via AccountOf edges).

Source

pub fn accounts_by(&self, source_id: &str) -> Vec<&Account>

All accounts authored by a given source.

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.