pub struct FileInfo<'a> {
pub filename: &'a str,
pub file_kind: FileKind,
pub is_executable: bool,
pub content: Option<&'a [u8]>,
}Expand description
Pre-loaded file information for I/O-free identification.
Use this when you have file data from a source other than the host filesystem (e.g., a mocked/virtual filesystem in tests).
§Examples
use file_identify::{tags_from_info, FileInfo, FileKind};
let info = FileInfo {
filename: "script.py",
file_kind: FileKind::Regular,
is_executable: false,
content: Some(b"print('hello')"),
};
let tags = tags_from_info(&info);
assert!(tags.contains("python"));
assert!(tags.contains("text"));Fields§
§filename: &'a strThe filename (just the name component, not a full path).
file_kind: FileKindThe kind of filesystem entry.
is_executable: boolWhether the file has executable permissions.
content: Option<&'a [u8]>Optional file content for shebang and encoding analysis.
Pass None to skip content-based analysis entirely.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for FileInfo<'a>
impl<'a> RefUnwindSafe for FileInfo<'a>
impl<'a> Send for FileInfo<'a>
impl<'a> Sync for FileInfo<'a>
impl<'a> Unpin for FileInfo<'a>
impl<'a> UnsafeUnpin for FileInfo<'a>
impl<'a> UnwindSafe for FileInfo<'a>
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