pub struct CapabilityDef {
pub name: CapName,
pub docs: String,
pub refines: Option<CapName>,
pub default: bool,
pub unprovided: Option<String>,
}Expand description
A capability declaration. A capability is a registered dotted name for a
state of processing that a stage brings about, such as
flm.blocks.structured: a stage declares the capabilities it provides and
the capabilities it requires, and a caller demands the capabilities it
wants.
A caller demands capabilities (PlanRequest::demand),
and the plan chooses stages that provide them, so nobody writes the
sequence of stages by hand. A capability may refine another: it is a
stronger form of the other one (flm.blocks.structured refines
flm.blocks), and a stage that provides the refinement also satisfies a
demand for the parent. At most one refinement of a parent may be marked as
its default; a demand for the parent alone selects the default refinement
when nothing else decides.
Every table’s name is already a capability, declared together with the
table. Declare a capability with this type only for a state that no table
represents: a marker, the result of a check, or the parent of
refinements. Register the declaration with
FeatureBuilder::capability.
It is written to data with Serialize; see serialized
forms.
§Examples
use flm_core::core::registry::CapabilityDef;
let parent = CapabilityDef::new("flm.blocks").docs("Content is grouped into blocks.");
let refined = CapabilityDef::new("flm.blocks.structured")
.refines("flm.blocks")
.default();
assert_eq!(refined.refines, Some(parent.name));
assert!(refined.default);Fields§
§name: CapNameThe capability’s dotted name.
docs: StringDocumentation prose.
refines: Option<CapName>The capability this one refines, if any. Some feature of the same registry must declare it, and a chain of refinements may not lead back to a capability already in it; the registry build checks both.
default: boolWhether this capability is the default refinement of its parent. At
most one refinement of a parent may set it, and setting it on a
capability that refines nothing is a build error
(BuildError::DefaultWithoutParent).
unprovided: Option<String>What a plan error says, after the workflow it names, when a plan needs
this capability and no registered stage provides it, in place of the
generic text: the condition in the words of the feature that declares the
capability, with its fix when the fix is not obvious. None keeps the
generic text (PlanError::Unsatisfiable).
Implementations§
Source§impl CapabilityDef
impl CapabilityDef
Sourcepub fn new(name: impl Into<CapName>) -> CapabilityDef
pub fn new(name: impl Into<CapName>) -> CapabilityDef
A capability called name, refining nothing, with no documentation.
Sourcepub fn unprovided(self, text: impl Into<String>) -> CapabilityDef
pub fn unprovided(self, text: impl Into<String>) -> CapabilityDef
Sets what a plan error says when no registered stage provides this
capability (unprovided). Returns self,
for chaining.
§Examples
use flm_core::core::registry::CapabilityDef;
let checked = CapabilityDef::new("example.checked")
.unprovided("no feature checks the examples; use a package that does");
assert!(checked.unprovided.is_some());Sourcepub fn docs(self, docs: impl Into<String>) -> CapabilityDef
pub fn docs(self, docs: impl Into<String>) -> CapabilityDef
Sets the documentation prose. Returns self, for chaining.
Sourcepub fn refines(self, parent: impl Into<CapName>) -> CapabilityDef
pub fn refines(self, parent: impl Into<CapName>) -> CapabilityDef
Makes this capability a refinement of parent, replacing any parent
set before. Returns self, for chaining.
Sourcepub fn default(self) -> CapabilityDef
pub fn default(self) -> CapabilityDef
Marks this capability as its parent’s default refinement. Returns
self, for chaining. Call refines as well:
a default refinement without a parent is a build error.
Trait Implementations§
Source§impl Clone for CapabilityDef
impl Clone for CapabilityDef
Source§impl Debug for CapabilityDef
impl Debug for CapabilityDef
impl Eq for CapabilityDef
Source§impl JsonSchema for CapabilityDef
impl JsonSchema for CapabilityDef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for CapabilityDef
impl PartialEq for CapabilityDef
Source§impl Serialize for CapabilityDef
impl Serialize for CapabilityDef
impl StructuralPartialEq for CapabilityDef
Auto Trait Implementations§
impl Forget for CapabilityDef
impl Freeze for CapabilityDef
impl Move for CapabilityDef
impl RefUnwindSafe for CapabilityDef
impl Send for CapabilityDef
impl Sync for CapabilityDef
impl Unpin for CapabilityDef
impl UnsafeUnpin for CapabilityDefwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for CapabilityDef
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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