Struct r3::bind::BindTable

source ·
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

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 BindRefs.

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.

Trait Implementations

The returned type after indexing.
Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.