Struct sway_types::source_engine::SourceEngine
source · pub struct SourceEngine { /* private fields */ }
Expand description
The Source Engine manages a relationship between file paths and their corresponding integer-based source IDs. Additionally, it maintains a reserve - a map that traces back from a source ID to its original file path. The primary objective of this system is to enable clients that need to reference a file path to do so using an integer-based ID. This numeric representation can be stored more efficiently as a key in a hashmap. The Source Engine is designed to be thread-safe. Its internal structures are secured by the RwLock mechanism. This allows its functions to be invoked using a straightforward non-mutable reference, ensuring safe concurrent access.
Implementations§
source§impl SourceEngine
impl SourceEngine
sourcepub fn get_source_id(&self, path: &PathBuf) -> SourceId
pub fn get_source_id(&self, path: &PathBuf) -> SourceId
This function retrieves an integer-based source ID for a provided path buffer. If an ID already exists for the given path, the function will return that existing ID. If not, a new ID will be created.