Skip to main content

Relationships

Struct Relationships 

Source
pub struct Relationships { /* private fields */ }
Expand description

Parsed relationship mapping from word/_rels/document.xml.rels.

Maps relationship IDs (e.g. rId5) to their targets for both image and hyperlink relationship types. Image targets are resolved to ZIP entry paths (e.g. word/media/image1.png), while hyperlink targets are stored as-is (typically an external URL).

Implementations§

Source§

impl Relationships

Source

pub fn parse(rels_xml: &str) -> Result<Self>

Parses relationship XML into image and hyperlink mappings.

Expects the standard OOXML relationships XML format:

<Relationships>
  <Relationship Id="rId5" Target="media/image1.png" Type="...image" />
  <Relationship Id="rId10" Target="https://example.com"
                Type="...hyperlink" TargetMode="External" />
</Relationships>

Image targets are resolved to ZIP entry paths (prepended with word/). Hyperlink targets are stored as-is (typically external URLs).

§Errors

Returns DocError::Format on XML parse failure.

Source

pub fn resolve(&self, rel_id: &str) -> Option<&str>

Resolves a relationship ID to its media part path in the ZIP archive.

Returns None if the relationship ID is not found among image relationships. This method is kept for backward compatibility; prefer resolve_image for new code.

Source

pub fn resolve_image(&self, rel_id: &str) -> Option<&str>

Resolves a relationship ID to its image part path in the ZIP archive.

Returns None if the relationship ID is not found among image relationships.

Resolves a relationship ID to its hyperlink URL.

Returns None if the relationship ID is not found among hyperlink relationships.

Source

pub fn len(&self) -> usize

Returns the number of image relationships parsed (for diagnostics).

Source

pub fn is_empty(&self) -> bool

Returns true if no relationships were parsed.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.