pub struct Reader {
pub header: Header,
/* private fields */
}Expand description
Index reader — mmaps the shard file for zero-copy lookups.
Fields§
§header: HeaderParsed shard header containing section offsets and sizes.
Implementations§
Source§impl Reader
impl Reader
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open and memory-map an index file for reading.
§Errors
Returns an error if the file cannot be opened, memory-mapped, or its header is invalid.
Sourcepub fn get_last_modified(root: &Path) -> Result<u64>
pub fn get_last_modified(root: &Path) -> Result<u64>
Get the last modification time among all source files in the tree.
§Errors
Returns an error if the directory walk fails or metadata cannot be read.
Sourcepub fn get_trigram(&self, trigram: Trigram) -> Option<TrigramInfo>
pub fn get_trigram(&self, trigram: Trigram) -> Option<TrigramInfo>
Binary search the trigram table. Returns None if the trigram
is unknown.
When CDX compression is active, performs a two-level search: first on the block index, then within the decompressed block.
Sourcepub fn decode_postings(&self, info: &TrigramInfo) -> Result<PostingList>
pub fn decode_postings(&self, info: &TrigramInfo) -> Result<PostingList>
Decode the posting list for a given trigram info.
§Errors
Returns an error if the posting data is out of bounds or corrupted.
Sourcepub fn get_file(&self, file_id: u32) -> Result<FileInfo>
pub fn get_file(&self, file_id: u32) -> Result<FileInfo>
Retrieve file metadata by its ID.
§Errors
Returns an error if the file ID is out of bounds or the file table entry is malformed.
Sourcepub fn bloom_may_contain(&self, file_id: u32, trigram: Trigram) -> bool
pub fn bloom_may_contain(&self, file_id: u32, trigram: Trigram) -> bool
Check if a bloom filter for a file may contain a trigram.
Returns true if the trigram may be present (conservative) or if
any error occurs reading the bloom data (safe default: assume present).
Sourcepub const fn metadata(&self) -> ShardMetadata
pub const fn metadata(&self) -> ShardMetadata
Retrieve high-level shard metadata without parsing the full header.
Sourcepub fn is_stale(&self, path: &Path) -> bool
pub fn is_stale(&self, path: &Path) -> bool
Detect whether the shard file on disk has been rebuilt under this live mmap.
Returns true if the inode or file size differs, or if the file no longer exists.
A stale reader should be dropped and reopened.
On Unix: uses inode comparison (inode changes on atomic rename). On non-Unix: uses file size comparison only (Windows file locking prevents rebuild under live mmap, so size-only detection is sufficient).
Auto Trait Implementations§
impl Freeze for Reader
impl RefUnwindSafe for Reader
impl Send for Reader
impl Sync for Reader
impl Unpin for Reader
impl UnsafeUnpin for Reader
impl UnwindSafe for Reader
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> 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