pub struct SourceText {
pub encoding: TextEncoding,
pub utf8_bom: bool,
pub by_extension: Option<&'static LanguageInfo>,
pub by_content: Option<&'static LanguageInfo>,
}Expand description
Details of a FileClass::SourceText result.
Fields§
§encoding: TextEncodingProbable encoding of the bytes.
utf8_bom: booltrue when the file starts with a UTF-8 BOM. Usually implied by
TextEncoding::Utf8Bom, but also set when the bytes after the BOM
are not valid UTF-8 and encoding is therefore Latin1.
by_extension: Option<&'static LanguageInfo>The language the file’s extension maps to, if any (registry lookup).
by_content: Option<&'static LanguageInfo>The language the file’s content suggests (shebang / <?php), if any.
Implementations§
Source§impl SourceText
impl SourceText
Sourcepub fn likely_language(&self) -> Option<&'static LanguageInfo>
pub fn likely_language(&self) -> Option<&'static LanguageInfo>
Best single guess: the extension’s language, else the content’s.
Sourcepub fn extension_agrees(&self) -> Option<bool>
pub fn extension_agrees(&self) -> Option<bool>
Some(true) / Some(false) when both hints exist and agree /
disagree; None when either is missing. A hint only — never a gate.
Trait Implementations§
Source§impl Clone for SourceText
impl Clone for SourceText
impl Copy for SourceText
Auto Trait Implementations§
impl Forget for SourceText
impl Freeze for SourceText
impl Move for SourceText
impl RefUnwindSafe for SourceText
impl Send for SourceText
impl Sync for SourceText
impl Unpin for SourceText
impl UnsafeUnpin for SourceText
impl UnwindSafe for SourceText
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