pub trait Decoder {
// Required method
fn get_entity(&self, name: &str) -> Option<&str>;
// Provided methods
fn decode_entity(&self, name: &str) -> Result<DecodedEntity<'_>> { ... }
fn decode_string<'a>(&self, s: &'a str) -> Result<Cow<'a, str>> { ... }
}Expand description
Trait for decoding entities to values.
Required Methods§
Sourcefn get_entity(&self, name: &str) -> Option<&str>
fn get_entity(&self, name: &str) -> Option<&str>
Retrieves the definition for an entity by name.
Provided Methods§
Sourcefn decode_entity(&self, name: &str) -> Result<DecodedEntity<'_>>
fn decode_entity(&self, name: &str) -> Result<DecodedEntity<'_>>
Decodes an entity by either parsing a numeric entity (e.g. " ") or calling
get_entity.
Sourcefn decode_string<'a>(&self, s: &'a str) -> Result<Cow<'a, str>>
fn decode_string<'a>(&self, s: &'a str) -> Result<Cow<'a, str>>
Decodes an entire string, replacing all entities inside it with their values resolved by
decode_entity. If the string does not contain any entities, it is
returned unchanged as a borrowed string slice. Otherwise, an owned string containing the
replacements is returned.
Implementations on Foreign Types§
Source§impl Decoder for ()
Fallback Decoder that only looks up global entities (with Entity::global).
impl Decoder for ()
Fallback Decoder that only looks up global entities (with Entity::global).