#[non_exhaustive]pub struct LangFilePath {
pub pkg_name: Txt,
pub pkg_version: Version,
pub file: Txt,
}Expand description
Localization resource file path in the localization directory.
In the default directory layout, localization dependencies are collected using cargo zng l10n
and copied to l10n/{lang}/deps/{name}/{version}/, and localization for the app (is_current_app)
is placed in l10n/{lang}/.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.pkg_name: TxtPackage name.
pkg_version: VersionPackage version.
file: TxtThe localization file name, without extension.
Implementations§
Source§impl LangFilePath
impl LangFilePath
Sourcepub fn new(
pkg_name: impl Into<Txt>,
pkg_version: Version,
file: impl Into<Txt>,
) -> LangFilePath
pub fn new( pkg_name: impl Into<Txt>, pkg_version: Version, file: impl Into<Txt>, ) -> LangFilePath
New from package name, version and file.
Sourcepub fn current_app(file: impl Into<Txt>) -> LangFilePath
pub fn current_app(file: impl Into<Txt>) -> LangFilePath
Gets a file in the current app.
This value indicates that the localization resources are directly on the l10n/{lang?}/ directories, not
in the dependencies directories.
See zng_env::about() for more details.
Sourcepub fn is_current_app(&self) -> bool
pub fn is_current_app(&self) -> bool
Gets if this file is in the current_app resources, or the pkg_name is empty or the pkg_version.pre is #.#.#-local.
Sourcepub fn pkg_name(&self) -> Txt
pub fn pkg_name(&self) -> Txt
Gets the normalized package name.
This is the app package name if is_current_app, otherwise is just the pkg_name value.
Sourcepub fn pkg_version(&self) -> Version
pub fn pkg_version(&self) -> Version
Gets the normalized package version.
This is the app version if is_current_app, otherwise is just the pkg_version value.
Sourcepub fn to_path(&self, lang: &Lang) -> PathBuf
pub fn to_path(&self, lang: &Lang) -> PathBuf
Get the file path, relative to the localization dir.
- Empty file name is the same as
_. - If package
is_current_appgets{lang}/{file}.ftl. - Else if is another package gets
{lang}/deps/{pkg_name}/{pkg_version}/{file}.ftl.
Sourcepub fn matches(&self, search: &LangFilePath) -> Option<u64>
pub fn matches(&self, search: &LangFilePath) -> Option<u64>
Gets a value that indicates if the resources represented by self can be used for search.
The number indicates the quality of the match:
0is an exact match.b1is a match with only versionbuilddifferences.b10is a match with only versionpredifferences.(0..u16::MAX) << 16is a match with onlypatchdifferences and the absolute distance.(0..u16::MAX) << 16 * 2is a match withminordifferences and the absolute distance.(0..u16::MAX) << 16 * 3is a match withmajordifferences and the absolute distance.None`` is apkg_name` mismatch.
Trait Implementations§
Source§impl Clone for LangFilePath
impl Clone for LangFilePath
Source§fn clone(&self) -> LangFilePath
fn clone(&self) -> LangFilePath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LangFilePath
impl Debug for LangFilePath
Source§impl<'de> Deserialize<'de> for LangFilePath
impl<'de> Deserialize<'de> for LangFilePath
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LangFilePath, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LangFilePath, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<&'static str> for LangFilePath
impl From<&'static str> for LangFilePath
Source§fn from(file: &'static str) -> LangFilePath
fn from(file: &'static str) -> LangFilePath
Source§impl From<String> for LangFilePath
impl From<String> for LangFilePath
Source§fn from(file: String) -> LangFilePath
fn from(file: String) -> LangFilePath
Source§impl From<Txt> for LangFilePath
impl From<Txt> for LangFilePath
Source§fn from(file: Txt) -> LangFilePath
fn from(file: Txt) -> LangFilePath
Source§impl Hash for LangFilePath
impl Hash for LangFilePath
Source§impl IntoVar<LangFilePath> for &'static str
impl IntoVar<LangFilePath> for &'static str
fn into_var(self) -> Var<LangFilePath>
Source§impl IntoVar<LangFilePath> for String
impl IntoVar<LangFilePath> for String
fn into_var(self) -> Var<LangFilePath>
Source§impl IntoVar<LangFilePath> for Txt
impl IntoVar<LangFilePath> for Txt
fn into_var(self) -> Var<LangFilePath>
Source§impl Ord for LangFilePath
impl Ord for LangFilePath
Source§fn cmp(&self, other: &LangFilePath) -> Ordering
fn cmp(&self, other: &LangFilePath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for LangFilePath
impl PartialEq for LangFilePath
Source§impl PartialOrd for LangFilePath
impl PartialOrd for LangFilePath
Source§impl Serialize for LangFilePath
impl Serialize for LangFilePath
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for LangFilePath
impl IntoValue<LangFilePath> for &'static str
impl IntoValue<LangFilePath> for String
impl IntoValue<LangFilePath> for Txt
Auto Trait Implementations§
impl Freeze for LangFilePath
impl RefUnwindSafe for LangFilePath
impl Send for LangFilePath
impl Sync for LangFilePath
impl Unpin for LangFilePath
impl UnwindSafe for LangFilePath
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more