Trait r3_core::kernel::cfg::KernelStatic
source · pub trait KernelStatic<System = Self>: CfgPhase2<System> { }Expand description
Associates static data to a system type.
The members of this trait are implementation details and not meant to be
used externally. Use attach_phase3! or DelegateKernelStatic
to implement this trait.
Derivation and Usage
This is one of the traits implemented by the kernel-independent
configuration process. This process is divided into three phases. The
first phase involves the following steps, mostly happening in a
macro-generated function (let’s call this do_cfg_phase1):
do_cfg_phase1constructs aC: constCfgBaseand binds it to a local variablec.do_cfg_phase1invokescfg_phase1!, passing&mut c, to construct and bind aCfg<C>to a local variableb.do_cfg_phase1invokes an application-provided configuration function to register objects throughb.do_cfg_phase1callsCfg::finish_phase1to obtain aCfgPhase1Data.do_cfg_phase1returns thisCfgPhase1Data.- Using this
CfgPhase1Data,attach_phase1!producesstaticitems and an implementation ofCfgPhase1forC::System(directly or indirectly throughDelegateKernelStatic).
The remaining phases repeat these steps using the prospective macros and
functions as well as the constant values derived so far (through the
implemented traits), each time recreating C and Cfg<C> from scratch.
The final phase produces the finalized C, which the kernel-specific
configuration process can use to complete the rest of the configuration
process. (Cs produced by other phases are incomplete and therefore
should be disregarded.) The final phase also produces an implementation of
KernelStatic for C::System.
Rationale: Usually
const fns can’t use constant values derived by themselves as constant values, but splitting into multiple phases makes this possible.The current implementation doesn’t fully utilize all of the three phases. The extra phases are kept to leave room for future internal changes.
The following diagram outlines the data flow in this process.