Skip to main content

Location

Struct Location 

Source
#[non_exhaustive]
pub struct Location { pub venue_name: Option<String>, pub address: Option<Address>, pub latitude: Option<f64>, pub longitude: Option<f64>, pub virtual_url: Option<String>, }
Expand description

Where an event takes place — corresponds to schema.org Event.location.

Schema.org accepts Place, PostalAddress, Text, or VirtualLocation as a value for Event.location. This crate models all four flavours inside one struct so a single Location can describe a purely physical venue, a purely virtual one, or a hybrid:

  • venue_name carries the textual name of the venue (Place.name), e.g. "Worthy Farm" or "Madison Square Garden".
  • address carries the postal address (PostalAddress).
  • latitude / longitude carry geographic coordinates (Place.geo).
  • virtual_url carries the join URL for VirtualLocation.

Every field is optional. A Location with all fields None is equivalent to no location at all and is skipped by the matcher.

§Example

use event_matcher::{Address, Location};

let l = Location::new()
    .with_venue_name("Worthy Farm")
    .with_address(Address::new().with_postcode("BA4 4BY"))
    .with_latitude(51.150_3)
    .with_longitude(-2.586_2);

assert_eq!(l.venue_name.as_deref(), Some("Worthy Farm"));
assert_eq!(l.latitude, Some(51.150_3));

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.
§venue_name: Option<String>

Textual name of the venue, e.g. "Madison Square Garden".

§address: Option<Address>

Postal address of the physical venue.

§latitude: Option<f64>

Latitude in decimal degrees. Conventionally [-90.0, 90.0]. Values outside that range or non-finite values are stored as supplied for round-trip honesty, but the coordinates scorer treats them as missing.

§longitude: Option<f64>

Longitude in decimal degrees. Conventionally [-180.0, 180.0].

§virtual_url: Option<String>

Join URL for a virtual event (schema.org VirtualLocation.url), e.g. "https://zoom.us/j/123456". Compared by exact equality after trimming whitespace.

Implementations§

Source§

impl Location

Source

pub fn new() -> Self

Construct an empty location with every field set to None.

Source

pub fn with_venue_name(self, value: impl Into<String>) -> Self

Fluent setter for venue_name.

Source

pub fn with_address(self, value: Address) -> Self

Fluent setter for address.

Source

pub fn with_latitude(self, value: f64) -> Self

Fluent setter for latitude.

Source

pub fn with_longitude(self, value: f64) -> Self

Fluent setter for longitude.

Source

pub fn with_virtual_url(self, value: impl Into<String>) -> Self

Fluent setter for virtual_url.

Trait Implementations§

Source§

impl Clone for Location

Source§

fn clone(&self) -> Location

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 Location

Source§

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

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

impl Default for Location

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Location

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 Location

Source§

fn eq(&self, other: &Location) -> 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 Location

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 Location

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> 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.