pub struct BindTable<System> { /* private fields */ }
Expand description
Represents a permission to dereference BindRef
.
Example
#![feature(const_trait_impl)]
#![feature(const_mut_refs)]
use r3_core::{
bind::{Bind, BindRef, BindTable},
kernel::{cfg::Cfg, traits, StaticTask},
prelude::*,
};
const fn configure_app<C>(cfg: &mut Cfg<C>)
where
C: ~const traits::CfgTask,
C::System: traits::KernelStatic,
{
let foo = Bind::define().init(|| {
// `BindTable::get()` will fail because some bindings might not
// be initialized at this point
assert!(BindTable::<C::System>::get().is_err());
42
}).finish(cfg).as_ref();
StaticTask::define()
.start(move || {
// Task code can get `BindTable` because tasks can only
// run after the boot phase is complete
let bt = BindTable::get().unwrap();
assert_eq!(bt[foo], 42);
})
.priority(2)
.active(true)
.finish(cfg);
}
Implementations§
source§impl<System> BindTable<System>where
System: KernelBase + KernelStatic,
impl<System> BindTable<System>where System: KernelBase + KernelStatic,
sourcepub fn get() -> Result<&'static Self, GetBindTableError>
pub fn get() -> Result<&'static Self, GetBindTableError>
Get a reference to BindTable
if the boot phase is complete.
Returns Err(BadContext)
if the boot phase hasn’t completed yet, and
therefore it’s unsafe to dereference BindRef
s.
sourcepub const unsafe fn get_unchecked() -> &'static Self
pub const unsafe fn get_unchecked() -> &'static Self
Get a reference to BindTable
without checking if it’s safe to do so
in the current context.
Safety
The returned reference may be used to borrow binding contents that are uninitialized or being mutably borrowed by a binding initializer.