pub struct SafetyContext {
pub file_default: SafetyMode,
pub function_overrides: Vec<(FunctionSignature, SafetyMode)>,
pub source_file: Option<String>,
}Fields§
§file_default: SafetyMode§function_overrides: Vec<(FunctionSignature, SafetyMode)>§source_file: Option<String>Implementations§
Source§impl SafetyContext
impl SafetyContext
pub fn new() -> Self
Sourcepub fn merge_header_annotations(&mut self, header_cache: &HeaderCache)
pub fn merge_header_annotations(&mut self, header_cache: &HeaderCache)
Merge safety annotations from headers into this context
Sourcepub fn should_check_function(&self, func_name: &str) -> bool
pub fn should_check_function(&self, func_name: &str) -> bool
Check if a specific function should be checked
Sourcepub fn is_from_source_file(&self, file_path: &str) -> bool
pub fn is_from_source_file(&self, file_path: &str) -> bool
Check if a file path is from the source file where annotations were parsed Returns true if the file path matches the source file, false otherwise
Sourcepub fn get_function_safety(&self, func_name: &str) -> SafetyMode
pub fn get_function_safety(&self, func_name: &str) -> SafetyMode
Get the safety mode of a specific function
Sourcepub fn get_class_safety(&self, class_name: &str) -> SafetyMode
pub fn get_class_safety(&self, class_name: &str) -> SafetyMode
Get the safety mode of a specific class This is similar to get_function_safety but specifically handles class-level annotations
Sourcepub fn get_class_safety_for_file(
&self,
class_name: &str,
class_file: &str,
) -> SafetyMode
pub fn get_class_safety_for_file( &self, class_name: &str, class_file: &str, ) -> SafetyMode
Get the safety mode of a class, considering its source file location
IMPORTANT: file_default only applies to classes from the source file being analyzed. Classes from other files (system headers, external libraries) are treated as Undeclared unless they have an explicit annotation.
This fixes the namespace collision bug where a user’s @safe namespace annotation was incorrectly applying to STL classes from system headers.
Sourcepub fn get_function_safety_for_file(
&self,
func_name: &str,
func_file: &str,
) -> SafetyMode
pub fn get_function_safety_for_file( &self, func_name: &str, func_file: &str, ) -> SafetyMode
Get the safety mode of a function, considering its source file location
IMPORTANT: file_default only applies to functions from the source file being analyzed. Functions from other files are treated as Undeclared unless explicitly annotated.
Sourcepub fn should_check_function_for_file(
&self,
func_name: &str,
func_file: &str,
) -> bool
pub fn should_check_function_for_file( &self, func_name: &str, func_file: &str, ) -> bool
Check if a function should be checked, considering its source file location
Trait Implementations§
Source§impl Clone for SafetyContext
impl Clone for SafetyContext
Source§fn clone(&self) -> SafetyContext
fn clone(&self) -> SafetyContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more