Skip to main content

CallbackPolicy

Trait CallbackPolicy 

Source
pub unsafe trait CallbackPolicy: 'static {
    type Cell<T>;
    type Owner<T>: Deref<Target = Self::Cell<T>> + Clone;
    type Guard<'a, T: 'a>: DerefMut<Target = T>;

    // Required methods
    fn new<T>(value: T) -> Self::Cell<T>;
    fn new_owned<T>(value: T) -> Self::Owner<T>;
    fn lock<T>(cell: &Self::Cell<T>) -> Self::Guard<'_, T>;
    fn is_in_use<T>(cell: &Self::Cell<T>) -> bool;
}
Expand description

Callback storage is selected at compile time. There is no trait-object call.

§Safety

Cloning an Owner<T> must keep the same Cell<T> allocation alive. Its address is passed to C, which may keep it until the last registered handler is removed. lock must prevent overlapping mutable access to that cell.

Required Associated Types§

Source

type Cell<T>

Source

type Owner<T>: Deref<Target = Self::Cell<T>> + Clone

Clones keep the same callback allocation alive while C holds its raw pointer.

Source

type Guard<'a, T: 'a>: DerefMut<Target = T>

Required Methods§

Source

fn new<T>(value: T) -> Self::Cell<T>

Source

fn new_owned<T>(value: T) -> Self::Owner<T>

Source

fn lock<T>(cell: &Self::Cell<T>) -> Self::Guard<'_, T>

Source

fn is_in_use<T>(cell: &Self::Cell<T>) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CallbackPolicy for LocalCallback

Source§

type Cell<T> = RefCell<T>

Source§

type Owner<T> = Rc<RefCell<T>>

Source§

type Guard<'a, T: 'a> = RefMut<'a, T>

Source§

impl CallbackPolicy for SharedCallback

Source§

type Cell<T> = Mutex<T>

Source§

type Owner<T> = Arc<Mutex<T>>

Source§

type Guard<'a, T: 'a> = MutexGuard<'a, T>