[][src]Struct marked::EncodingHint

pub struct EncodingHint { /* fields omitted */ }

A set of confidence-weighted evidence that a text document is in a particular encoding.

Implementations

impl EncodingHint[src]

pub fn shared_default(enc: &'static Encoding) -> SharedEncodingHint[src]

Construct a new Encoding hint with the specified encoding at DEFAULT_CONF confidence, wrapped for sharing.

pub fn shared_with_hint(
    enc: &'static Encoding,
    confidence: f32
) -> SharedEncodingHint
[src]

Construct a new Encoding hint with the specified encoding and confidence, wrapped for sharing.

pub fn add_label_hint<L>(&mut self, enc: L, confidence: f32) -> bool where
    L: AsRef<[u8]>, 
[src]

Add a hint for an encoding, by label ASCII-intepreted bytes, and some positive confidence value. If no encoding (or applicable replacement) is found for the specified label, returns false. Return true if an encoding is found and this hint changes the top confidence encoding.

pub fn add_hint(&mut self, enc: &'static Encoding, confidence: f32) -> bool[src]

Add a hint for the specified encoding and some positive confidence value. Return true if this hint changes the top most confident encoding.

pub fn could_read_from(&self, enc: &'static Encoding) -> bool[src]

Return true if the given encoding name could be read with both any current top encoding and from the provided encoding, from the same source bytes.

All supported encoding names are ASCII, so any parsed name encoding hint that would transition from an ASCII-compatible encoding (e.g. Windows-1252, UTF-8) to an ASCII-incompatible encoding (e.g. UTF-16, REPLACEMENT), or vice-versa, or to different ASCII-incompatible encodings (e.g. UTF-16BE to UTF-16LE) is nonsensical and should be ignored.

Note that this check should only be applied to text hints in the document itself, and not applied to hints from Byte-Order-Marks since they aren't ASCII names, or the HTTP Content-Type header since it isn't part of the document body.

pub fn top(&self) -> Option<&'static Encoding>[src]

Return the top (most confident) encoding, if at least one encoding has been hinted.

pub fn confidence(&self) -> f32[src]

Return the summed confidence value for the top (most confident) encoding. Returns 0.0 if no hint has been provided.

pub fn errors(&self) -> u32[src]

Return the total errors accumulated since construction or the last call to clear_errors.

pub fn increment_error(&mut self)[src]

Increment errors count by one.

pub fn changed(&self) -> Option<&'static Encoding>[src]

Return the latest top encoding if the top has changed since construction or the last call to clear_changed.

pub fn clear_changed(&mut self)[src]

Clear changed flag.

pub fn clear_errors(&mut self)[src]

Clear errors count.

Trait Implementations

impl Debug for EncodingHint[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.