Struct i18n_config::Crate[][src]

pub struct Crate<'a> {
    pub name: String,
    pub version: String,
    pub path: PathBuf,
    pub parent: Option<&'a Crate<'a>>,
    pub config_file_path: PathBuf,
    pub i18n_config: Option<I18nConfig>,
}

Represents a rust crate.

Fields

name: String

The name of the crate.

version: String

The version of the crate.

path: PathBuf

The path to the crate.

parent: Option<&'a Crate<'a>>

Path to the parent crate which is triggering the localization for this crate.

config_file_path: PathBuf

The file path expected to be used for i18n_config relative to this crate’s root.

i18n_config: Option<I18nConfig>

The localization config for this crate (if it exists).

Implementations

impl<'a> Crate<'a>[src]

pub fn from<P1: Into<PathBuf>, P2: Into<PathBuf>>(
    path: P1,
    parent: Option<&'a Crate<'_>>,
    config_file_path: P2
) -> Result<Crate<'a>, I18nConfigError>
[src]

Read crate from Cargo.toml i18n config using the config_file_path (if there is one).

pub fn module_name(&self) -> String[src]

The name of the module/library used for this crate. Replaces - characters with _ in the crate name.

pub fn parent_active_config(
    &'a self
) -> Result<Option<(&'a Crate<'_>, &'a I18nConfig)>, I18nConfigError>
[src]

If there is a parent, get it’s I18nConfig#active_config(), otherwise return None.

pub fn active_config(
    &'a self
) -> Result<Option<(&'a Crate<'_>, &'a I18nConfig)>, I18nConfigError>
[src]

Identify the config which should be used for this crate, and the crate (either this crate or one of it’s parents) associated with that config.

pub fn config_or_err(&self) -> Result<&I18nConfig, I18nConfigError>[src]

Get the I18nConfig in this crate, or return an error if there is none present.

pub fn gettext_config_or_err(&self) -> Result<&GettextConfig, I18nConfigError>[src]

Get the GettextConfig in this crate, or return an error if there is none present.

pub fn collated_subcrate(&self) -> bool[src]

If this crate has a parent, check whether the parent wants to collate subcrates string extraction, as per the parent’s GettextConfig#collate_extracted_subcrates. This also requires that the current crate’s GettextConfig#extract_to_parent is true.

Returns false if there is no parent or the parent has no gettext config.

pub fn find_parent(&self) -> Option<Crate<'a>>[src]

Attempt to resolve the parents of this crate which have this crate listed as a subcrate in their i18n config.

Trait Implementations

impl<'a> Clone for Crate<'a>[src]

impl<'a> Debug for Crate<'a>[src]

impl<'a> Display for Crate<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Crate<'a>

impl<'a> Send for Crate<'a>

impl<'a> Sync for Crate<'a>

impl<'a> Unpin for Crate<'a>

impl<'a> UnwindSafe for Crate<'a>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.