pub struct LinkMetadata {
pub href: String,
pub text: String,
pub title: Option<String>,
pub link_type: LinkType,
pub rel: Vec<String>,
pub attributes: BTreeMap<String, String>,
}Expand description
Hyperlink metadata with categorization and attributes.
Represents <a> elements with parsed href values, text content, and link type classification.
§Examples
let link = LinkMetadata {
href: "https://example.com".to_string(),
text: "Example".to_string(),
title: Some("Visit Example".to_string()),
link_type: LinkType::External,
rel: vec!["nofollow".to_string()],
attributes: Default::default(),
};
assert_eq!(link.link_type, LinkType::External);
assert_eq!(link.text, "Example");Fields§
§href: StringThe href URL value
text: StringLink text content (normalized, concatenated if mixed with elements)
title: Option<String>Optional title attribute (often shown as tooltip)
link_type: LinkTypeLink type classification
rel: Vec<String>Rel attribute values (e.g., “nofollow”, “stylesheet”, “canonical”)
attributes: BTreeMap<String, String>Additional HTML attributes
Implementations§
Source§impl LinkMetadata
impl LinkMetadata
Sourcepub fn classify_link(href: &str) -> LinkType
pub fn classify_link(href: &str) -> LinkType
Classify a link based on href value.
§Arguments
href- The href attribute value
§Returns
Appropriate LinkType based on protocol and content.
§Examples
assert_eq!(LinkMetadata::classify_link("#section"), LinkType::Anchor);
assert_eq!(LinkMetadata::classify_link("mailto:test@example.com"), LinkType::Email);
assert_eq!(LinkMetadata::classify_link("tel:+1234567890"), LinkType::Phone);
assert_eq!(LinkMetadata::classify_link("https://example.com"), LinkType::External);Trait Implementations§
Source§impl Clone for LinkMetadata
impl Clone for LinkMetadata
Source§fn clone(&self) -> LinkMetadata
fn clone(&self) -> LinkMetadata
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinkMetadata
impl Debug for LinkMetadata
Source§impl<'de> Deserialize<'de> for LinkMetadata
impl<'de> Deserialize<'de> for LinkMetadata
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
Auto Trait Implementations§
impl Freeze for LinkMetadata
impl RefUnwindSafe for LinkMetadata
impl Send for LinkMetadata
impl Sync for LinkMetadata
impl Unpin for LinkMetadata
impl UnwindSafe for LinkMetadata
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)