pub struct Event {
pub id: EventId,
pub location: Location,
pub timestamp: Timestamp,
pub text: String,
pub metadata: HashMap<String, String>,
pub sources: Vec<SourceRef>,
pub tags: Vec<String>,
}Expand description
An event in a spatial narrative.
Events are the fundamental unit of spatial narratives. Each event represents something that happened at a specific place and time.
§Examples
use spatial_narrative::core::{Event, Location, Timestamp, SourceRef};
let event = Event::builder()
.location(Location::new(40.7128, -74.0060))
.timestamp(Timestamp::now())
.text("Protest began at City Hall")
.tag("protest")
.tag("politics")
.source(SourceRef::article("https://news.example.com/protest"))
.metadata("participants", "5000")
.build();Fields§
§id: EventIdUnique identifier.
location: LocationGeographic location.
timestamp: TimestampWhen the event occurred.
text: StringDescription of the event.
metadata: HashMap<String, String>Key-value metadata.
sources: Vec<SourceRef>References to source material.
Categorical tags.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(
location: Location,
timestamp: Timestamp,
text: impl Into<String>,
) -> Self
pub fn new( location: Location, timestamp: Timestamp, text: impl Into<String>, ) -> Self
Creates a new event with required fields.
Sourcepub fn builder() -> EventBuilder
pub fn builder() -> EventBuilder
Creates a builder for constructing an Event.
Sourcepub fn remove_tag(&mut self, tag: &str)
pub fn remove_tag(&mut self, tag: &str)
Removes a tag from the event.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&str>
pub fn get_metadata(&self, key: &str) -> Option<&str>
Gets a metadata value.
Sourcepub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
Sets a metadata value.
Sourcepub fn add_source(&mut self, source: SourceRef)
pub fn add_source(&mut self, source: SourceRef)
Adds a source reference.
Sourcepub fn to_geo_point(&self) -> Point<f64>
pub fn to_geo_point(&self) -> Point<f64>
Returns the location as a geo-types Point.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
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
Source§impl SpatialEntity for Event
impl SpatialEntity for Event
Source§fn to_geo_point(&self) -> Point<f64>
fn to_geo_point(&self) -> Point<f64>
Returns the location as a geo-types Point.
Source§fn is_within_bounds(&self, bounds: &GeoBounds) -> bool
fn is_within_bounds(&self, bounds: &GeoBounds) -> bool
Checks if this entity is within the given bounds.
Source§impl TemporalEntity for Event
impl TemporalEntity for Event
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
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