pub struct SchemaNode {
pub types: Vec<String>,
pub properties: IndexMap<String, Vec<SchemaValue>>,
pub source_format: SourceFormat,
pub source_location: Option<SourceLocation>,
}Expand description
A single structured data node (e.g. a Product, an Offer).
Each node represents one Schema.org entity extracted from the HTML
document, retaining its SourceFormat so callers can distinguish
which markup produced it.
§Examples
use schemaorg_rs::types::{SchemaNode, SchemaValue, SourceFormat};
use indexmap::IndexMap;
let node = SchemaNode {
types: vec!["Product".into()],
properties: IndexMap::from([(
"name".into(),
vec![SchemaValue::Text("Widget".into())],
)]),
source_format: SourceFormat::JsonLd,
source_location: None,
};
assert_eq!(node.id(), None);Fields§
§types: Vec<String>Schema.org type(s), e.g. ["Product", "IndividualProduct"].
properties: IndexMap<String, Vec<SchemaValue>>Properties: key -> list of values (insertion-ordered).
source_format: SourceFormatSource format that this node was extracted from.
source_location: Option<SourceLocation>Location in the original HTML document.
Implementations§
Source§impl SchemaNode
impl SchemaNode
Sourcepub fn id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
Returns the @id of this node, if present.
§Examples
use schemaorg_rs::types::{SchemaNode, SchemaValue, SourceFormat};
use indexmap::IndexMap;
let node = SchemaNode {
types: vec!["Product".into()],
properties: IndexMap::from([(
"@id".into(),
vec![SchemaValue::Text("#product1".into())],
)]),
source_format: SourceFormat::JsonLd,
source_location: None,
};
assert_eq!(node.id(), Some("#product1"));Trait Implementations§
Source§impl Clone for SchemaNode
impl Clone for SchemaNode
Source§fn clone(&self) -> SchemaNode
fn clone(&self) -> SchemaNode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SchemaNode
impl Debug for SchemaNode
Source§impl<'de> Deserialize<'de> for SchemaNode
impl<'de> Deserialize<'de> for SchemaNode
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 PartialEq for SchemaNode
impl PartialEq for SchemaNode
Source§fn eq(&self, other: &SchemaNode) -> bool
fn eq(&self, other: &SchemaNode) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for SchemaNode
impl Serialize for SchemaNode
impl StructuralPartialEq for SchemaNode
Auto Trait Implementations§
impl Freeze for SchemaNode
impl RefUnwindSafe for SchemaNode
impl Send for SchemaNode
impl Sync for SchemaNode
impl Unpin for SchemaNode
impl UnsafeUnpin for SchemaNode
impl UnwindSafe for SchemaNode
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