pub struct FileItem {
pub size: u64,
pub modified: u64,
pub access_frecency_score: i16,
pub modification_frecency_score: i16,
pub git_recency_score: i16,
pub git_status: Option<Status>,
/* private fields */
}Fields§
§size: u64§modified: u64§access_frecency_score: i16§modification_frecency_score: i16§git_recency_score: i16§git_status: Option<Status>Implementations§
Source§impl FileItem
impl FileItem
pub fn new( path: PathBuf, base_path: &Path, git_status: Option<Status>, ) -> (Self, String)
Sourcepub fn new_from_walk(
path: &Path,
base_path: &Path,
git_status: Option<Status>,
metadata: Option<&Metadata>,
) -> (Self, String)
pub fn new_from_walk( path: &Path, base_path: &Path, git_status: Option<Status>, metadata: Option<&Metadata>, ) -> (Self, String)
Create a FileItem with an empty ChunkedString from a path on disk.
Returns (file_item, relative_path_string). The relative path must be
kept alongside the FileItem until build_chunked_path_store_and_assign
populates each item’s path field from the shared arena.
Sourcepub fn new_from_walk_parts(
path: &Path,
base_path: &Path,
git_status: Option<Status>,
size: u64,
modified: u64,
) -> (Self, String)
pub fn new_from_walk_parts( path: &Path, base_path: &Path, git_status: Option<Status>, size: u64, modified: u64, ) -> (Self, String)
Like Self::new_from_walk but takes already-extracted size and
modification time (Unix seconds) instead of a std::fs::Metadata.
Used by the zlob walker backend, which fetches metadata in bulk.
Sourcepub fn new_from_walk_bytes(
path: &Path,
relative_path: &[u8],
basename_offset: u16,
git_status: Option<Status>,
size: u64,
modified: u64,
) -> (Self, String)
pub fn new_from_walk_bytes( path: &Path, relative_path: &[u8], basename_offset: u16, git_status: Option<Status>, size: u64, modified: u64, ) -> (Self, String)
Zlob-walker fast path: skip the pathdiff::diff_paths PathBuf alloc by
taking the already-relative slice and the basename-offset that zlob’s
scanner computed during traversal. ~80–120 ms saved on a chromium scan
(500k entries × one fewer alloc + no component walk).
relative_path is root-relative bytes; basename_offset is the byte
offset where the basename begins (e.g. zlob’s `entry.path_bytes().len()
- entry.file_name().as_os_str().as_encoded_bytes().len()
minus therelative_offset`).
Source§impl FileItem
impl FileItem
pub fn new_raw( filename_start: u16, size: u64, modified: u64, git_status: Option<Status>, is_binary: bool, ) -> Self
Sourcepub fn absolute_path(
&self,
arena: impl FFFStringStorage,
base_path: &Path,
) -> PathBuf
pub fn absolute_path( &self, arena: impl FFFStringStorage, base_path: &Path, ) -> PathBuf
Returns an absolute path of the file
pub fn dir_str(&self, arena: impl FFFStringStorage) -> String
pub fn file_name(&self, arena: impl FFFStringStorage) -> String
pub fn relative_path(&self, arena: impl FFFStringStorage) -> String
pub fn relative_path_len(&self) -> usize
pub fn filename_offset_in_relative_path(&self) -> usize
pub fn total_frecency_score(&self) -> i32
pub fn is_binary(&self) -> bool
pub fn set_binary(&self, val: bool)
pub fn is_deleted(&self) -> bool
pub fn is_overflow(&self) -> bool
pub fn set_overflow(&self, val: bool)
Source§impl FileItem
impl FileItem
Sourcepub fn invalidate_mmap(&mut self, budget: &ContentCacheBudget)
pub fn invalidate_mmap(&mut self, budget: &ContentCacheBudget)
Invalidate the cached mmap content, has to be called every time the file is updated.
Call this when the background watcher detects that the file has been modified. On Unix, a file that is truncated while mapped can cause SIGBUS. On Windows, the stale buffer simply won’t reflect the new contents. In both cases, invalidating ensures a fresh read on the next access.
pub fn update_metadata( &mut self, budget: &ContentCacheBudget, modified_secs: Option<u64>, new_size: Option<u64>, )
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FileItem
impl RefUnwindSafe for FileItem
impl Send for FileItem
impl Sync for FileItem
impl Unpin for FileItem
impl UnsafeUnpin for FileItem
impl UnwindSafe for FileItem
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<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