#[non_exhaustive]pub struct Thing {Show 13 fields
pub name: Option<String>,
pub alternate_names: Vec<String>,
pub description: Option<String>,
pub disambiguating_description: Option<String>,
pub identifiers: Vec<Identifier>,
pub url: Option<String>,
pub image: Option<String>,
pub same_as: Vec<String>,
pub main_entity_of_page: Option<String>,
pub additional_types: Vec<String>,
pub subject_of: Vec<String>,
pub owner: Option<String>,
pub local_id: Option<String>,
}Expand description
Core data structure for a thing, aligned with schema.org/Thing.
Every field is optional (or defaults to empty). The matcher tolerates
missing data field-by-field — a None value never penalises a thing.
See crate::matcher::MatchingEngine::match_things for how missing
fields affect the weighted score.
Construct via Thing::builder rather than struct literal syntax so
the call-site stays compact and forward-compatible if fields are added.
§Example
use thing_matcher::Thing;
let t = Thing::builder()
.name("Eiffel Tower")
.add_alternate_name("La Tour Eiffel")
.description("Wrought-iron lattice tower on the Champ de Mars in Paris.")
.url("https://www.toureiffel.paris/")
.build();
assert_eq!(t.name.as_deref(), Some("Eiffel Tower"));
assert_eq!(t.alternate_names, vec!["La Tour Eiffel".to_string()]);Thing round-trips through serde.
let t = Thing::builder().name("Eiffel Tower").build();
let json = serde_json::to_string(&t).unwrap();
let back: Thing = serde_json::from_str(&json).unwrap();
assert_eq!(t, back);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: Option<String>Primary canonical name. Corresponds to schema.org/name.
alternate_names: Vec<String>Aliases, endonyms, or translations. Corresponds to
schema.org/alternateName. The matcher takes the best score
across the cartesian product of primary + alternates.
description: Option<String>Free-form description. Corresponds to schema.org/description.
disambiguating_description: Option<String>Short disambiguating description. Corresponds to
schema.org/disambiguatingDescription.
identifiers: Vec<Identifier>Scheme-scoped external identifiers. Corresponds to
schema.org/identifier modelled as PropertyValue. Sharing any
one (property_id, value) pair across two things is a
deterministic match.
url: Option<String>Canonical URL of the item. Corresponds to schema.org/url.
image: Option<String>URL of a representative image. Corresponds to schema.org/image.
same_as: Vec<String>Reference URLs that unambiguously indicate the same item, e.g. a
Wikipedia article or an authority record. Corresponds to
schema.org/sameAs.
main_entity_of_page: Option<String>Page (URL) for which this thing is the main entity. Corresponds
to schema.org/mainEntityOfPage.
additional_types: Vec<String>Additional types from external vocabularies, typically schema.org
subtypes or other ontology URIs. Corresponds to
schema.org/additionalType.
subject_of: Vec<String>Works or events about this thing (URLs). Corresponds to
schema.org/subjectOf.
owner: Option<String>Person or organisation that owns this thing. Corresponds to
schema.org/owner. Stored as a string (a name or URL) — the
crate does not model Person / Organization separately.
local_id: Option<String>Local identifier issued by the originating system. Not normalised, not scored — different organisations may issue colliding values. Kept for round-trip honesty.
Implementations§
Source§impl Thing
impl Thing
Sourcepub fn builder() -> ThingBuilder
pub fn builder() -> ThingBuilder
Begin constructing a Thing with the ThingBuilder.
All fields default to None / empty until a setter is called.
§Example
use thing_matcher::Thing;
let t = Thing::builder()
.name("Big Ben")
.build();
assert_eq!(t.name.as_deref(), Some("Big Ben"));Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate that the thing carries a primary name.
Returns Ok(()) if name is set. Otherwise returns
crate::MatchingError::MissingField.
This is not invoked automatically by the matcher — call it at the system boundary when you ingest data, not on every comparison.
§Example
use thing_matcher::Thing;
assert!(Thing::builder().name("Eiffel Tower").build().validate().is_ok());
assert!(Thing::builder().build().validate().is_err());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Thing
impl<'de> Deserialize<'de> for Thing
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>,
impl Eq for Thing
impl StructuralPartialEq for Thing
Auto Trait Implementations§
impl Freeze for Thing
impl RefUnwindSafe for Thing
impl Send for Thing
impl Sync for Thing
impl Unpin for Thing
impl UnsafeUnpin for Thing
impl UnwindSafe for Thing
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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