Struct r3_core::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§

source§

impl<System> BindTable<System>where System: KernelBase + KernelStatic,

source

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

source

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.

Trait Implementations§

source§

impl<System, T> Index<BindRef<System, T>> for BindTable<System>where System: KernelBase + KernelStatic, T: 'static,

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: BindRef<System, T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<System> RefUnwindSafe for BindTable<System>

§

impl<System> Send for BindTable<System>

§

impl<System> Sync for BindTable<System>

§

impl<System> Unpin for BindTable<System>

§

impl<System> UnwindSafe for BindTable<System>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.