Enum FtlOutputOptions

Source
pub enum FtlOutputOptions {
    MultiFile {
        output_ftl_folder: String,
    },
    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.

Defaults to a SingleFileOptions with the output_ftl_folder set to “gen” and gzip set to true.

Variants§

§

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

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

§

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

§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

Source

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

Source

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

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.