DatabaseReader

Trait DatabaseReader 

Source
pub trait DatabaseReader {
Show 13 methods // Required methods fn get_id(&self, name: &str) -> Option<FileId>; fn get(&self, id: &FileId) -> Result<Arc<File>, DatabaseError>; fn get_ref(&self, id: &FileId) -> Result<&File, DatabaseError>; fn get_by_name(&self, name: &str) -> Result<Arc<File>, DatabaseError>; fn get_by_path(&self, path: &Path) -> Result<Arc<File>, DatabaseError>; fn files(&self) -> impl Iterator<Item = Arc<File>>; fn len(&self) -> usize; // Provided methods fn files_with_type( &self, file_type: FileType, ) -> impl Iterator<Item = Arc<File>> { ... } fn files_without_type( &self, file_type: FileType, ) -> impl Iterator<Item = Arc<File>> { ... } fn file_ids(&self) -> impl Iterator<Item = FileId> { ... } fn file_ids_with_type( &self, file_type: FileType, ) -> impl Iterator<Item = FileId> { ... } fn file_ids_without_type( &self, file_type: FileType, ) -> impl Iterator<Item = FileId> { ... } fn is_empty(&self) -> bool { ... }
}
Expand description

A universal interface for reading data from any database implementation.

This trait provides a common API for querying file data, abstracting over whether the underlying source is the mutable Database or the read-optimized ReadDatabase. This allows for writing generic code that can operate on either.

Required Methods§

Source

fn get_id(&self, name: &str) -> Option<FileId>

Retrieves a file’s stable ID using its logical name.

Source

fn get(&self, id: &FileId) -> Result<Arc<File>, DatabaseError>

Retrieves a reference to a file using its stable FileId.

§Errors

Returns DatabaseError::FileNotFound if no file with the given ID exists.

Source

fn get_ref(&self, id: &FileId) -> Result<&File, DatabaseError>

Retrieves a reference to a file using its stable FileId.

§Errors

Returns DatabaseError::FileNotFound if no file with the given ID exists.

Source

fn get_by_name(&self, name: &str) -> Result<Arc<File>, DatabaseError>

Retrieves a reference to a file using its logical name.

§Errors

Returns DatabaseError::FileNotFound if no file with the given name exists.

Source

fn get_by_path(&self, path: &Path) -> Result<Arc<File>, DatabaseError>

Retrieves a reference to a file by its absolute filesystem path.

§Errors

Returns DatabaseError::FileNotFound if no file with the given path exists.

Source

fn files(&self) -> impl Iterator<Item = Arc<File>>

Returns an iterator over all files in the database.

The order is not guaranteed for Database, but is sorted by FileId for ReadDatabase, providing deterministic iteration.

Source

fn len(&self) -> usize

Returns the total number of files in the database.

Provided Methods§

Source

fn files_with_type( &self, file_type: FileType, ) -> impl Iterator<Item = Arc<File>>

Returns an iterator over all files of a specific FileType.

Source

fn files_without_type( &self, file_type: FileType, ) -> impl Iterator<Item = Arc<File>>

Returns an iterator over all files that do not match a specific FileType.

Source

fn file_ids(&self) -> impl Iterator<Item = FileId>

Returns an iterator over the stable IDs of all files in the database.

Source

fn file_ids_with_type( &self, file_type: FileType, ) -> impl Iterator<Item = FileId>

Returns an iterator over the stable IDs of all files of a specific FileType.

Source

fn file_ids_without_type( &self, file_type: FileType, ) -> impl Iterator<Item = FileId>

Returns an iterator over the stable IDs of all files that do not match a specific FileType.

Source

fn is_empty(&self) -> bool

Returns true if the database contains no files.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§