pub struct Narrative {
pub id: NarrativeId,
pub title: String,
pub events: Vec<Event>,
pub metadata: NarrativeMetadata,
pub tags: Vec<String>,
}Expand description
A collection of related events forming a coherent story.
Narratives are the primary container for organizing events into meaningful stories with geographic and temporal structure.
§Examples
use spatial_narrative::core::{Narrative, Event, Location, Timestamp};
let mut narrative = Narrative::builder()
.title("Hurricane Timeline")
.description("Tracking the hurricane's path")
.category("disaster")
.build();
narrative.add_event(Event::builder()
.location(Location::new(25.0, -80.0))
.timestamp(Timestamp::now())
.text("Hurricane makes landfall")
.tag("landfall")
.build());Fields§
§id: NarrativeIdUnique identifier.
title: StringTitle of the narrative.
events: Vec<Event>Events in this narrative.
metadata: NarrativeMetadataNarrative metadata.
Categorical tags for the narrative.
Implementations§
Source§impl Narrative
impl Narrative
Sourcepub fn builder() -> NarrativeBuilder
pub fn builder() -> NarrativeBuilder
Creates a builder for constructing a Narrative.
Sourcepub fn events_mut(&mut self) -> &mut Vec<Event>
pub fn events_mut(&mut self) -> &mut Vec<Event>
Returns a mutable reference to the events.
Sourcepub fn remove_event(&mut self, id: &EventId) -> Option<Event>
pub fn remove_event(&mut self, id: &EventId) -> Option<Event>
Removes an event by ID.
Sourcepub fn get_event_mut(&mut self, id: &EventId) -> Option<&mut Event>
pub fn get_event_mut(&mut self, id: &EventId) -> Option<&mut Event>
Finds an event by ID (mutable).
Sourcepub fn events_chronological(&self) -> Vec<&Event>
pub fn events_chronological(&self) -> Vec<&Event>
Returns events sorted by timestamp.
Sourcepub fn filter_spatial(&self, bounds: &GeoBounds) -> Vec<&Event>
pub fn filter_spatial(&self, bounds: &GeoBounds) -> Vec<&Event>
Filters events by spatial bounds.
Sourcepub fn filter_temporal(&self, range: &TimeRange) -> Vec<&Event>
pub fn filter_temporal(&self, range: &TimeRange) -> Vec<&Event>
Filters events by time range.
Sourcepub fn filter_by_tag(&self, tag: &str) -> Vec<&Event>
pub fn filter_by_tag(&self, tag: &str) -> Vec<&Event>
Filters events by tag.
Sourcepub fn time_range(&self) -> Option<TimeRange>
pub fn time_range(&self) -> Option<TimeRange>
Returns the time range spanning all events.
Returns all unique tags used by events in this narrative.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Narrative
impl<'de> Deserialize<'de> for Narrative
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Narrative
Auto Trait Implementations§
impl Freeze for Narrative
impl RefUnwindSafe for Narrative
impl Send for Narrative
impl Sync for Narrative
impl Unpin for Narrative
impl UnwindSafe for Narrative
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