Struct i18n_config::Crate

source ·
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>,
}
Expand description

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§

source§

impl<'a> Crate<'a>

source

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

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

source

pub fn module_name(&self) -> String

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

source

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

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

source

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

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.

source

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

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

source

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

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

source

pub fn collated_subcrate(&self) -> bool

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.

source

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

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

Trait Implementations§

source§

impl<'a> Clone for Crate<'a>

source§

fn clone(&self) -> Crate<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Crate<'a>

source§

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

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

impl<'a> Display for Crate<'a>

source§

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

Formats the value using the given formatter. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.