pub struct Identifier {
pub property_id: String,
pub value: String,
}Expand description
External identifier for a thing, modelled on schema.org/PropertyValue.
Two Identifier values are equal iff both their property_id and their
value are equal. Equality is structural — no per-scheme
canonicalisation is performed.
property_id is the issuer or vocabulary that names the identifier,
such as "wikidata", "isbn", "doi", "gtin", or a fully-qualified
URL. value is the identifier string itself.
§Example
use thing_matcher::Identifier;
let a = Identifier::new("wikidata", "Q243").unwrap();
let b = Identifier::new("wikidata", " Q243 ").unwrap();
assert_eq!(a, b, "values are trimmed at construction");
assert!(Identifier::new("wikidata", "").is_none());Fields§
§property_id: StringIssuer or vocabulary that scopes the identifier, e.g.
"wikidata", "isbn", "doi", "gtin", or a URL.
value: StringThe identifier value, trimmed of surrounding whitespace.
Implementations§
Source§impl Identifier
impl Identifier
Sourcepub fn new(
property_id: impl Into<String>,
value: impl Into<String>,
) -> Option<Self>
pub fn new( property_id: impl Into<String>, value: impl Into<String>, ) -> Option<Self>
Construct an Identifier, trimming the value and property id of
surrounding whitespace. Returns None if either trimmed component
is empty.
No further normalisation is applied — different vocabularies have different rules and the crate makes no assumptions.
§Example
use thing_matcher::Identifier;
let id = Identifier::new("wikidata", " Q243 ").unwrap();
assert_eq!(id.value, "Q243");
assert_eq!(id.property_id, "wikidata");
assert!(Identifier::new("wikidata", " ").is_none());
assert!(Identifier::new(" ", "Q243").is_none());Trait Implementations§
Source§impl Clone for Identifier
impl Clone for Identifier
Source§fn clone(&self) -> Identifier
fn clone(&self) -> Identifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Identifier
impl Debug for Identifier
Source§impl<'de> Deserialize<'de> for Identifier
impl<'de> Deserialize<'de> for Identifier
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>,
Source§impl Hash for Identifier
impl Hash for Identifier
Source§impl PartialEq for Identifier
impl PartialEq for Identifier
Source§fn eq(&self, other: &Identifier) -> bool
fn eq(&self, other: &Identifier) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Identifier
impl Serialize for Identifier
impl Eq for Identifier
impl StructuralPartialEq for Identifier
Auto Trait Implementations§
impl Freeze for Identifier
impl RefUnwindSafe for Identifier
impl Send for Identifier
impl Sync for Identifier
impl Unpin for Identifier
impl UnsafeUnpin for Identifier
impl UnwindSafe for Identifier
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