Skip to main content

ExtractOptions

Struct ExtractOptions 

Source
#[non_exhaustive]
pub struct ExtractOptions { pub source_lang: Option<String>, pub target_lang: Option<String>, pub granularity: Granularity, pub include_locked: bool, pub limits: Option<Limits>, pub format_options: BTreeMap<String, String>, pub profile: Option<String>, }
Expand description

Options for Filter::extract. Build them with ExtractOptions::new and the with_* methods (ExtractOptions::new().with_target_lang("de-DE")); new options are added without breaking callers.

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.
§source_lang: Option<String>

The source language (a BCP 47 tag, en, de-DE), when known.

§target_lang: Option<String>

The target language, when known.

§granularity: Granularity

Parsers always extract one segment per unit; bilingua-seg applies the granularity afterwards.

§include_locked: bool

Extract text the format marks as not translatable as locked units (for context), instead of skipping it.

§limits: Option<Limits>

Safety limits for this call; None uses Limits::default (Localization OS’s numbers).

§format_options: BTreeMap<String, String>

Options only one format knows, as "<format>.<name>" to a text value ("ftl.translate_terms" to "true"). Each filter declares its keys and their kind (Filter::format_option_keys); the bilingua facade refuses a key no filter declares, or a value of the wrong kind, with Error::FormatOption. Booleans are true/false/1/0/yes/no/on/off; integers are decimal.

§profile: Option<String>

A behaviour profile (profile): Some("locos") for the Localization OS adapter. None: Bilingua’s own behaviour. The bilingua facade refuses a name it does not know.

Implementations§

Source§

impl ExtractOptions

Source

pub fn with_profile(self, profile: impl IntoOptionString) -> ExtractOptions

Switches a profile on ("locos"), or off with None.

Source

pub fn is_profile(&self, name: &str) -> bool

True when this profile is on.

Source

pub fn new() -> ExtractOptions

The defaults: no languages, sentence granularity, locked text skipped, Localization OS’s limits.

Source

pub fn with_source_lang(self, lang: impl IntoOptionString) -> ExtractOptions

Sets (or with None clears) the source language; it picks the sentence rules.

Source

pub fn with_target_lang(self, lang: impl IntoOptionString) -> ExtractOptions

Sets (or clears) the target language.

Source

pub fn with_granularity(self, granularity: Granularity) -> ExtractOptions

Sets the granularity.

Source

pub fn with_include_locked(self, include_locked: bool) -> ExtractOptions

Extracts locked text as locked units, for context.

Source

pub fn with_limits(self, limits: impl Into<Option<Limits>>) -> ExtractOptions

Limits for this call (Limits or Option<Limits>; None is the defaults).

Source

pub fn with_format_option( self, key: impl Into<String>, value: impl ToString, ) -> ExtractOptions

Sets one format option ("<format>.<name>"); the value is text (true, 42, name=Name).

Source

pub fn with_format_options( self, options: BTreeMap<String, String>, ) -> ExtractOptions

Replaces all format options.

Source

pub fn format_option(&self, key: &str) -> Option<&str>

A format option as text, if set.

Source

pub fn format_flag(&self, key: &str) -> Option<bool>

A format option as a boolean (true, 1, yes, on are true; false, 0, no, off are false; any other text or no entry gives None).

Source

pub fn format_int(&self, key: &str) -> Option<i64>

A format option as an integer (None when unset or not a decimal integer).

Source

pub fn limits(&self) -> Limits

The limits in force: the caller’s, or the defaults.

Trait Implementations§

Source§

impl Clone for ExtractOptions

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 Debug for ExtractOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ExtractOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for ExtractOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ExtractOptions

Source§

impl PartialEq for ExtractOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ExtractOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ExtractOptions

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.