pub struct LanguageDetector { /* private fields */ }
Expand description
Detector for identifying language codes from filesystem paths.
Implementations§
Source§impl LanguageDetector
impl LanguageDetector
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LanguageDetector
with default language mappings and patterns.
Initializes internal dictionaries and regex patterns for detection. Do not translate these language codes to English rustdoc!!!
Sourcepub fn detect_from_path(&self, path: &Path) -> Option<LanguageInfo>
pub fn detect_from_path(&self, path: &Path) -> Option<LanguageInfo>
Detect a single language information from the given path.
§Behavior
Attempts detection by directory name first, then by filename pattern.
Sourcepub fn get_primary_language(&self, path: &Path) -> Option<String>
pub fn get_primary_language(&self, path: &Path) -> Option<String>
Return the primary detected language code for the provided path.
§Returns
Some(code)
if detected, otherwise None
.
Sourcepub fn detect_all_languages(&self, path: &Path) -> Vec<LanguageInfo>
pub fn detect_all_languages(&self, path: &Path) -> Vec<LanguageInfo>
Collect all potential language detections from the path.
Sorts results by confidence and removes duplicates by code.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LanguageDetector
impl RefUnwindSafe for LanguageDetector
impl Send for LanguageDetector
impl Sync for LanguageDetector
impl Unpin for LanguageDetector
impl UnwindSafe for LanguageDetector
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
Mutably borrows from an owned value. Read more