pub enum Locale {
En,
PtBr,
}Expand description
Resolved UI locale for stderr prose.
Not #[non_exhaustive]: only en and pt-BR ship in the MVP binary and
exhaustive matches in this crate are intentional.
Variants§
Implementations§
Source§impl Locale
impl Locale
Sourcepub fn resolve(explicit: Option<&str>) -> AppResult<Self>
pub fn resolve(explicit: Option<&str>) -> AppResult<Self>
Resolve locale with fail-closed explicit tags and soft system fallback.
Precedence: explicit (CLI/config) → DOCSRS_CLI_LANG → system locale → en.
Explicit and env tags that are not en / pt-BR (and en-* variants)
return InvalidInput (exit 65). Unknown system locales soft-fallback to English.
§Errors
Returns ErrorKind::InvalidInput when an explicit or env tag is unsupported.
Sourcepub fn parse_supported(tag: &str) -> AppResult<Self>
pub fn parse_supported(tag: &str) -> AppResult<Self>
Parse an explicit lang tag. Fail-closed.
Accepted after normalization:
en,en-US,en_GB,en.UTF-8, …pt-BR,pt_BR,pt-br,pt_BR.UTF-8(region must be BR)
Rejected: bare pt, pt-PT, fr, empty, unknown tags.
§Errors
Returns ErrorKind::InvalidInput when tag is empty or unsupported.
Sourcepub fn from_system() -> Self
pub fn from_system() -> Self
Soft-detect from OS locale (unknown tags → English).
Called after tracing init in the binary path. Logs when the OS returns
no locale so detection failure is visible under -v / RUST_LOG.
Sourcepub fn soft_from_tag(tag: &str) -> Self
pub fn soft_from_tag(tag: &str) -> Self
Soft map a system/BCP47-ish tag (never errors).
Any primary language pt (including pt, pt-PT, pt_BR.UTF-8) maps
to Locale::PtBr for the MVP bilingual bundle.
Sourcepub fn progress_fetching(self, target: &str) -> String
pub fn progress_fetching(self, target: &str) -> String
Progress line after the 2s threshold.
Sourcepub fn error_prefix(self) -> &'static str
pub fn error_prefix(self) -> &'static str
Prefix for human stderr errors.
Sourcepub fn format_error(self, technical_en: &str) -> String
pub fn format_error(self, technical_en: &str) -> String
Human-readable stderr line for a technical English message.
Trait Implementations§
impl Copy for Locale
impl Eq for Locale
impl StructuralPartialEq for Locale
Auto Trait Implementations§
impl Freeze for Locale
impl RefUnwindSafe for Locale
impl Send for Locale
impl Sync for Locale
impl Unpin for Locale
impl UnsafeUnpin for Locale
impl UnwindSafe for Locale
Blanket Implementations§
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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