pub trait SysBinding {
// Required methods
unsafe fn shutdown(&mut self) -> !;
unsafe fn panic(&self, error: Option<NonNullConst<u8>>) -> !;
unsafe fn has_function(&self, id: FnId) -> Bool;
unsafe fn get_function(&self, id: FnId) -> Optional<CBaseFn>;
unsafe fn lock(&self);
unsafe fn try_lock(&self) -> Bool;
unsafe fn unlock(&self);
unsafe fn get_sync_handler(&self) -> NonNullConst<SyncHandlerInterface>;
unsafe fn set_sync_handler(
&mut self,
handler: Option<NonNullConst<SyncHandlerInterface>>,
);
}Expand description
Helper trait for using the sys api.
Required Methods§
Sourceunsafe fn panic(&self, error: Option<NonNullConst<u8>>) -> !
unsafe fn panic(&self, error: Option<NonNullConst<u8>>) -> !
Execution of the program is stopped abruptly. The error may be logged.
§Safety
The function crosses the ffi boundary.
Sourceunsafe fn has_function(&self, id: FnId) -> Bool
unsafe fn has_function(&self, id: FnId) -> Bool
Checks if a function is implemented.
§Return
Bool::True if the function exists, Bool::False otherwise.
§Safety
The function crosses the ffi boundary.
Sourceunsafe fn get_function(&self, id: FnId) -> Optional<CBaseFn>
unsafe fn get_function(&self, id: FnId) -> Optional<CBaseFn>
Sourceunsafe fn lock(&self)
unsafe fn lock(&self)
Locks the interface.
The calling thread is stalled until the lock can be acquired. Only one thread can hold the lock at a time.
§Safety
The function crosses the ffi boundary.
Sourceunsafe fn try_lock(&self) -> Bool
unsafe fn try_lock(&self) -> Bool
Tries to lock the interface.
The function fails if another thread already holds the lock.
§Return
Bool::True on success and Bool::False otherwise.
§Safety
The function crosses the ffi boundary.
Sourceunsafe fn unlock(&self)
unsafe fn unlock(&self)
Unlocks the interface.
§Safety
The function crosses the ffi boundary. Trying to call this function without prior locking is undefined behaviour.
Sourceunsafe fn get_sync_handler(&self) -> NonNullConst<SyncHandlerInterface>
unsafe fn get_sync_handler(&self) -> NonNullConst<SyncHandlerInterface>
Sourceunsafe fn set_sync_handler(
&mut self,
handler: Option<NonNullConst<SyncHandlerInterface>>,
)
unsafe fn set_sync_handler( &mut self, handler: Option<NonNullConst<SyncHandlerInterface>>, )
Sets a new synchronization handler.
The default synchronization handler is used, if handler is Option::None.
§Uses
This function can be used by modules, that want to provide a more complex synchronization mechanism than the one presented by the default handler.
§Swapping
The swapping occurs in three steps:
- The new synchronization handler is locked.
- The new synchronization handler is set as the active synchronization handler.
- The old synchronization handler is unlocked.
§Note
Changing the synchronization handler may break some modules, if they depend on a specific synchronization handler.
§Safety
The function is not thread-safe and crosses the ffi boundary.