Entities

Struct Entities 

Source
pub struct Entities<'a> { /* private fields */ }
Expand description

A set of entities that should be unmapped and how they should be unmapped

Implementations§

Source§

impl<'a> Entities<'a>

Source

pub fn xml() -> Self

Create a new Entities set for XML entity parsing

Source

pub fn replace_entities(&self, inc_map: bool, s: &str) -> Option<String>

Replace general entity references and &#..; characters, using the map.

Return None if the string has no replacements required; else Some(new string).

The replacements that are used should also be replaced if this is expanding a general entity use.

We don’t handle parameter entities here yet (‘%thing;’)

However, the map should not be used for entity declaration contents in XML hence inc_map is provided. However, character entities &#..; are expanded in entity declarations.

Character entities are ALSO expanded when entities are used.

Another option would be to use two different Entities to handle the two different cases.

An ampersand (&#38;) may be escaped

numerically (&#38;#38;) or with a general entity (&amp;).

“ >

makes ‘example’ be

An ampersand (&) may be escaped numerically (&#38;) or with a general entity (&amp;).

and a reference in a doc to &example; is then replaced with a ‘p’ element with content

An ampersand (&) may be escaped numerically (&) or with a general entity (&).

Trait Implementations§

Source§

impl<'a> Default for Entities<'a>

Source§

fn default() -> Entities<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Entities<'a>

§

impl<'a> RefUnwindSafe for Entities<'a>

§

impl<'a> Send for Entities<'a>

§

impl<'a> Sync for Entities<'a>

§

impl<'a> Unpin for Entities<'a>

§

impl<'a> UnwindSafe for Entities<'a>

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 = Infallible

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.