Skip to main content

Event

Struct Event 

Source
#[non_exhaustive]
pub struct Event {
Show 25 fields pub name: Option<String>, pub alternate_names: Vec<String>, pub description: Option<String>, pub url: Option<String>, pub event_ids: Vec<EventId>, pub local_id: Option<String>, pub category: Option<EventCategory>, pub keywords: Vec<String>, pub in_language: Option<String>, pub typical_age_range: Option<String>, pub start_date: Option<String>, pub end_date: Option<String>, pub door_time: Option<String>, pub previous_start_date: Option<String>, pub event_status: Option<EventStatus>, pub event_attendance_mode: Option<EventAttendanceMode>, pub location: Option<Location>, pub country_code_as_iso_3166_1_alpha_2: Option<String>, pub organizer: Option<String>, pub performers: Vec<String>, pub maximum_attendee_capacity: Option<u32>, pub maximum_physical_attendee_capacity: Option<u32>, pub maximum_virtual_attendee_capacity: Option<u32>, pub is_accessible_for_free: Option<bool>, pub super_event_id: Option<String>,
}
Expand description

Core event data structure — corresponds to schema.org Event.

Every field is optional (or defaults to empty). The matcher tolerates missing data field-by-field — a None value never penalises an event. See crate::matcher::MatchingEngine::match_events for how missing fields affect the weighted score.

Construct via Event::builder rather than struct literal syntax so the call-site stays compact and forward-compatible if fields are added.

§Field mapping to schema.org

FieldSchema.org property
nameschema:name
alternate_namesschema:alternateName
descriptionschema:description
urlschema:url
event_idsschema:identifier
category(closest match to the subtype of schema:Event)
keywordsschema:keywords
in_languageschema:inLanguage
start_dateschema:startDate
end_dateschema:endDate
door_timeschema:doorTime
previous_start_dateschema:previousStartDate
event_statusschema:eventStatus
event_attendance_modeschema:eventAttendanceMode
locationschema:location
organizerschema:organizer
performersschema:performer
maximum_attendee_capacityschema:maximumAttendeeCapacity
maximum_physical_attendee_capacityschema:maximumPhysicalAttendeeCapacity
maximum_virtual_attendee_capacityschema:maximumVirtualAttendeeCapacity
is_accessible_for_freeschema:isAccessibleForFree
typical_age_rangeschema:typicalAgeRange
super_event_idschema:superEvent (id only)

§Example

use event_matcher::Event;

let e = Event::builder()
    .name("RustConf 2024")
    .add_alternate_name("RustConf '24")
    .start_date("2024-09-10T09:00:00Z")
    .end_date("2024-09-13T17:00:00Z")
    .organizer("Rust Foundation")
    .build();

assert_eq!(e.name.as_deref(), Some("RustConf 2024"));
assert_eq!(e.alternate_names, vec!["RustConf '24".to_string()]);

Event round-trips through serde.

let e = Event::builder().name("RustConf").build();
let json = serde_json::to_string(&e).unwrap();
let back: Event = serde_json::from_str(&json).unwrap();
assert_eq!(e, back);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: Option<String>

Primary canonical name of the event, e.g. "Glastonbury Festival 2024".

§alternate_names: Vec<String>

Aliases, translations, or alternative titles of the event, e.g. vec!["Glasto 2024".into()]. Default empty.

§description: Option<String>

Free-text description of the event (schema:description).

§url: Option<String>

Canonical URL for the event (schema:url).

§event_ids: Vec<EventId>

External scheme-scoped identifiers for the event. Sharing any one (scheme, value) pair across two events is a deterministic match.

§local_id: Option<String>

Local identifier issued by the originating system. Not normalised — different organisations may issue colliding values.

§category: Option<EventCategory>

Coarse-grained category of the event (see EventCategory).

§keywords: Vec<String>

Free-form descriptive tags (schema:keywords).

§in_language: Option<String>

Content language as an IETF BCP-47 tag, e.g. "en-GB", "fr". Stored as supplied; compared case-insensitively after trim.

§typical_age_range: Option<String>

Expected demographic age range, e.g. "7-9" (schema:typicalAgeRange).

§start_date: Option<String>

Start date or date-time in ISO 8601 form. Examples: "2024-06-26", "2024-06-26T09:00:00Z", "2024-06-26T09:00:00+01:00".

§end_date: Option<String>

End date or date-time in ISO 8601 form.

§door_time: Option<String>

Door-opening time (schema:doorTime) in ISO 8601 form.

§previous_start_date: Option<String>

Original start date prior to rescheduling (schema:previousStartDate).

§event_status: Option<EventStatus>

Current status — scheduled, cancelled, postponed, rescheduled, or moved online (see EventStatus).

§event_attendance_mode: Option<EventAttendanceMode>

Physical, virtual, or mixed (see EventAttendanceMode).

§location: Option<Location>

Where the event takes place — venue, address, coordinates, and/or virtual URL (see Location).

§country_code_as_iso_3166_1_alpha_2: Option<String>

Country code in ISO 3166-1 alpha-2 form, e.g. "GB", "US", "FR". Convenient quick lookup when Location::address is absent. Stored as supplied — no canonicalisation is performed at construction time. The matcher compares case-insensitively after trimming whitespace.

§organizer: Option<String>

Name of the organiser (person or organisation). Single string for simplicity; callers needing multiple organisers should join them with ", " or pre-pick a canonical organiser.

§performers: Vec<String>

Performer names — actors, bands, speakers, athletes (schema:performer). Compared as a best-of cartesian product.

§maximum_attendee_capacity: Option<u32>

Total expected capacity (schema:maximumAttendeeCapacity).

§maximum_physical_attendee_capacity: Option<u32>

Offline-attendance capacity (schema:maximumPhysicalAttendeeCapacity).

§maximum_virtual_attendee_capacity: Option<u32>

Online-attendance capacity (schema:maximumVirtualAttendeeCapacity).

§is_accessible_for_free: Option<bool>

True if the event is free to attend (schema:isAccessibleForFree).

§super_event_id: Option<String>

Identifier of the parent event (schema:superEvent). Stored as a free-form string so callers can carry whichever scheme they need.

Implementations§

Source§

impl Event

Source

pub fn builder() -> EventBuilder

Begin constructing an Event with the EventBuilder.

All fields default to None / empty until a setter is called.

§Example
use event_matcher::Event;

let e = Event::builder()
    .name("RustConf 2024")
    .build();

assert_eq!(e.name.as_deref(), Some("RustConf 2024"));
Source

pub fn validate(&self) -> Result<()>

Validate that the event carries a primary name.

Returns Ok(()) if name is set.

This is not invoked automatically by the matcher — call it at the system boundary when you ingest data, not on every comparison.

§Errors

Returns crate::MatchingError::MissingField if name is None.

§Example
use event_matcher::Event;

assert!(Event::builder().name("RustConf").build().validate().is_ok());
assert!(Event::builder().build().validate().is_err());

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Event

Source§

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 PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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 UnsafeUnpin for Event

§

impl UnwindSafe for Event

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.