SafetyContext

Struct SafetyContext 

Source
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

Source

pub fn new() -> Self

Source

pub fn merge_header_annotations(&mut self, header_cache: &HeaderCache)

Merge safety annotations from headers into this context

Source

pub fn should_check_function(&self, func_name: &str) -> bool

Check if a specific function should be checked

Source

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

Source

pub fn get_function_safety(&self, func_name: &str) -> SafetyMode

Get the safety mode of a specific function

Source

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

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> SafetyContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SafetyContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.