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§
Sourcefn get_id(&self, name: &str) -> Option<FileId>
fn get_id(&self, name: &str) -> Option<FileId>
Retrieves a file’s stable ID using its logical name.
Sourcefn get(&self, id: &FileId) -> Result<Arc<File>, DatabaseError>
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.
Sourcefn get_ref(&self, id: &FileId) -> Result<&File, DatabaseError>
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.
Sourcefn get_by_name(&self, name: &str) -> Result<Arc<File>, DatabaseError>
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.
Sourcefn get_by_path(&self, path: &Path) -> Result<Arc<File>, DatabaseError>
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.
Provided Methods§
Sourcefn files_with_type(
&self,
file_type: FileType,
) -> impl Iterator<Item = Arc<File>>
fn files_with_type( &self, file_type: FileType, ) -> impl Iterator<Item = Arc<File>>
Returns an iterator over all files of a specific FileType.
Sourcefn files_without_type(
&self,
file_type: FileType,
) -> impl Iterator<Item = Arc<File>>
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.
Sourcefn file_ids(&self) -> impl Iterator<Item = FileId>
fn file_ids(&self) -> impl Iterator<Item = FileId>
Returns an iterator over the stable IDs of all files in the database.
Sourcefn file_ids_with_type(
&self,
file_type: FileType,
) -> impl Iterator<Item = FileId>
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.
Sourcefn file_ids_without_type(
&self,
file_type: FileType,
) -> impl Iterator<Item = FileId>
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.
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.