Skip to main content

FtlOutputOptions

Enum FtlOutputOptions 

Source
#[non_exhaustive]
pub enum FtlOutputOptions {
#[non_exhaustive]
MultiFile { output_ftl_folder: String, },
#[non_exhaustive]
SingleFile { output_ftl_file: String, compressor: Option<Box<dyn Fn(Vec<u8>) -> Result<Vec<u8>, Box<dyn Error>>>>, }, }
Expand description

The ftl output options for the build command. This allows you to configure how the output ftl files are generated, and also what type of access code is generated.

Build it with FtlOutputOptions::single_file, FtlOutputOptions::single_compressed_file or FtlOutputOptions::multi_file (the default is a single uncompressed file at gen/translations.ftl).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
MultiFile

Generates FTL files as one file per language which means that individual resource files are appended into one file.

This is especially useful client-side when you don’t want to embed the files in the binary or download them all together.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§output_ftl_folder: String

The path to the where the output ftl files will be written. For convenience fluent-typed joins all ftl resources for each language into a single file.

Defaults to “gen/” in the root of the package.

§

#[non_exhaustive]
SingleFile

Generates FTL files as one file for all languages, which means that individual resource files are appended into one file.

This is preferred for when you embed the files in your binary which typically is done server-side and also client-side when the files are small enough to either embed in the binary or download in a html request.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§output_ftl_file: String

The path to the where the output ftl file will be written. For convenience fluent-typed joins all ftl resources for each language into a single file.

Defaults to “gen/translations.ftl” in the root of the package.

§compressor: Option<Box<dyn Fn(Vec<u8>) -> Result<Vec<u8>, Box<dyn Error>>>>

The compresssor is an closure that takes the ftl file content as a byte array, compresses it and returns the compressed bytes.

Any compression algorithm can be used, but it’s up to the user to import the necessary crate and do the compression and when using it decompress in the same manner.

Implementations§

Source§

impl FtlOutputOptions

Source

pub fn single_file(file: &str) -> Self

All languages joined into one uncompressed .ftl file at file, suitable for embedding in the binary (server-side) or a single download.

Source

pub fn single_compressed_file<F>(file: &str, compressor: F) -> Self
where F: Fn(Vec<u8>) -> Result<Vec<u8>, Box<dyn Error>> + 'static,

Like single_file, but the joined bytes are passed through compressor before being written. You bring the compression crate and must decompress the bytes the same way at load time.

Source

pub fn multi_file(folder: &str) -> Self

One .ftl file per language written into folder, for loading a single language on demand rather than embedding them all.

Source

pub fn generate(&self, locales: &[LangBundle]) -> Result<GeneratedFtl, String>

Trait Implementations§

Source§

impl Default for FtlOutputOptions

Source§

fn default() -> Self

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

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> 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.