pub struct PackageEntry {
pub name: Name,
pub uses: Vec<PackageEntry>,
pub features: Vec<Arc<dyn FlmFeature>>,
pub feature_order: Vec<FeatureChain>,
}Expand description
A package ready to register: a named bundle of features together with the packages it builds on.
A package is the unit in which features are shipped and registered
together; crate::stdlib::add_features adds the standard features to a
package. Pass a package to
RegistryBuilder::use_package,
which adds the features of the packages it uses first, then its own
features, in order, together with the chains of the feature order each
package states. The registry builder adds a package at most once,
however many times it is passed or used, so two packages may each use a
third and its features are still registered once. The order in which the
features are added is their implicit order; the chains may change it
(super::order).
§Examples
use std::sync::Arc;
use flm_core::core::registry::{
BuildError, FeatureBuilder, FeatureInfo, FlmFeature, PackageEntry,
};
struct Base;
impl FlmFeature for Base {
fn info(&self) -> FeatureInfo { FeatureInfo::new("base", "Base") }
fn register(&self, _b: &mut FeatureBuilder<'_>) -> Result<(), BuildError> { Ok(()) }
}
let base = PackageEntry::new("base").feature(Arc::new(Base));
let mine = PackageEntry::new("mine").uses(base);
assert_eq!(mine.uses.len(), 1);Fields§
§name: NameThe package’s name. The registry builder recognizes a package it has already registered by this name, so it treats two entries of the same name as the same package.
uses: Vec<PackageEntry>The packages this package uses; their features are registered before this package’s own features.
features: Vec<Arc<dyn FlmFeature>>The package’s own features, in the order they are added to the registry builder.
feature_order: Vec<FeatureChain>The chains of the feature order that the package states, such as
userdefs < mymacros for a package whose definitions are to apply
over those of userdefs. They may name the features of any
package; the registry build combines them with every other chain it is
given (super::order).
Implementations§
Source§impl PackageEntry
impl PackageEntry
Sourcepub fn new(name: impl Into<Name>) -> PackageEntry
pub fn new(name: impl Into<Name>) -> PackageEntry
A package called name, which uses no package and holds no feature
yet.
Sourcepub fn uses(self, package: PackageEntry) -> PackageEntry
pub fn uses(self, package: PackageEntry) -> PackageEntry
Adds a package this package uses, after those already added. Returns
self, for chaining.
Sourcepub fn feature(self, feature: Arc<dyn FlmFeature>) -> PackageEntry
pub fn feature(self, feature: Arc<dyn FlmFeature>) -> PackageEntry
Adds one of this package’s own features, after those already added.
Returns self, for chaining.
Sourcepub fn feature_order(self, chain: FeatureChain) -> PackageEntry
pub fn feature_order(self, chain: FeatureChain) -> PackageEntry
Adds one chain of the feature order that this package states, after
those already added. Returns self, for chaining.
§Examples
use flm_core::core::registry::{FeatureChain, PackageEntry};
let chain = FeatureChain::parse("userdefs < mine", "package mine")?;
let mine = PackageEntry::new("mine").feature_order(chain);
assert_eq!(mine.feature_order.len(), 1);Trait Implementations§
Source§impl Clone for PackageEntry
impl Clone for PackageEntry
Auto Trait Implementations§
impl !RefUnwindSafe for PackageEntry
impl !UnwindSafe for PackageEntry
impl Forget for PackageEntry
impl Freeze for PackageEntrywhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<PackageEntry>: Freeze,
PhantomData<Arc<dyn FlmFeature>>: Freeze,
PhantomData<FeatureChain>: Freeze,
impl Move for PackageEntry
impl Send for PackageEntry
impl Sync for PackageEntry
impl Unpin for PackageEntry
impl UnsafeUnpin for PackageEntrywhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<PackageEntry>: UnsafeUnpin,
PhantomData<Arc<dyn FlmFeature>>: UnsafeUnpin,
PhantomData<FeatureChain>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more