Skip to main content

DecodeOptions

Struct DecodeOptions 

Source
#[non_exhaustive]
pub struct DecodeOptions<'a> { pub declared: bool, pub source_lang: Option<&'a str>, pub limits: Limits, pub lossy_after_utf8_bom: bool, pub mark_before_legacy: bool, }
Expand description

How one text file is read. Build it with DecodeOptions::new (from the extraction options) or DecodeOptions::with_limits, then DecodeOptions::declared for a format that declares its charset.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§declared: bool

The format declares its charset in the file (HTML meta, XML declaration, PO Content-Type): honour a declared legacy charset, and write the declaration back when the file is merged.

§source_lang: Option<&'a str>

The project’s source language, which picks the legacy code page of an undeclared non-UTF-8 file.

§limits: Limits

The limits the decoded text is checked against.

§lossy_after_utf8_bom: bool

A UTF-8 byte order mark followed by bytes that are not UTF-8 is read as UTF-8 with replacement characters (U+FFFD), as Localization OS does for plain text and subtitles. Off: such a file is refused.

§mark_before_legacy: bool

A UTF-8 byte order mark followed by bytes that are not UTF-8 is read as a mark, and the bytes after it as an undeclared legacy file (Localization OS BOM read version 2, #799.4 / #800.4: its subtitle readers). The envelope tag records the mark (;bom8), so a merge writes it back: before the code page’s bytes, or before UTF-8 when the text is written as UTF-8. Off: the mark’s three bytes are read as code-page text.

Implementations§

Source§

impl<'a> DecodeOptions<'a>

Source

pub fn new(opts: &'a ExtractOptions) -> DecodeOptions<'a>

The options of one extraction: its source language and its limits.

Source

pub fn with_limits(limits: Limits) -> DecodeOptions<'static>

No source language, not declared, these limits.

Source

pub fn with_source_lang(self, lang: Option<&'a str>) -> Self

The source language that picks the code page of an undeclared legacy file.

Source

pub fn lossy_after_utf8_bom(self) -> Self

Source

pub fn mark_before_legacy(self) -> Self

Source

pub fn declared(self) -> Self

The same, for a format that declares its charset in the file.

Trait Implementations§

Source§

impl<'a> Clone for DecodeOptions<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for DecodeOptions<'a>

Source§

impl<'a> Debug for DecodeOptions<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Forget for DecodeOptions<'a>

§

impl<'a> Freeze for DecodeOptions<'a>

§

impl<'a> RefUnwindSafe for DecodeOptions<'a>

§

impl<'a> Send for DecodeOptions<'a>

§

impl<'a> Sync for DecodeOptions<'a>

§

impl<'a> Unpin for DecodeOptions<'a>

§

impl<'a> UnsafeUnpin for DecodeOptions<'a>

§

impl<'a> UnwindSafe for DecodeOptions<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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.