pub struct PieceDecl {
pub name: Name,
pub table: TableHandle<Piece>,
pub place: PiecePlace,
pub default_on: bool,
pub docs: String,
}Expand description
The declaration of one piece: its name, the table that holds its content, where a backend places it, and whether a render places it by default.
A feature that offers a piece does three things:
- it contributes this declaration to the service slot
flm.piecesas a peer contribution (FeatureBuilder::peer_slot), so that the feature also builds in a registry without thepiecesfeature; - it declares the table
PieceDecl::table, of value typePiece(FeatureBuilder::table); - it registers the builder stage that writes that table.
When two pieces have the same place, a backend places them in the order of
their contributions to the slot. Which pieces a render places is decided
by selected_pieces.
§Examples
use flm_core::core::piece::{PieceDecl, PiecePlace};
let decl = PieceDecl::new("my.notes", PiecePlace::AfterContent, "the notes");
assert_eq!(decl.table.name().as_str(), "my.notes");
assert!(decl.default_on);
assert!(!decl.default_on(false).default_on);Fields§
§name: NameThe piece’s name: a dotted name the contributing feature owns, such as
mypkg.notes. The render options
(PiecesRenderOptions)
refer to the piece by this name.
table: TableHandle<Piece>The table holding the piece’s content, whose value type is always
Piece. PieceDecl::new gives it the piece’s name; the builder
stage declares it as a table it writes
(StageDecl::writes).
place: PiecePlaceWhere a backend places the piece.
default_on: boolWhether every render places the piece unless the render options leave
it out. A piece declared false is placed only when the render options
include it.
docs: StringA description of the piece, written by the feature that offers it.
Implementations§
Source§impl PieceDecl
impl PieceDecl
Sourcepub fn new(
name: impl Into<Name>,
place: PiecePlace,
docs: impl Into<String>,
) -> PieceDecl
pub fn new( name: impl Into<Name>, place: PiecePlace, docs: impl Into<String>, ) -> PieceDecl
Returns the declaration of the piece name, placed at place and
placed by default, whose content is held in the table of the same name
as the piece, with the description docs.
Sourcepub fn default_on(self, on: bool) -> PieceDecl
pub fn default_on(self, on: bool) -> PieceDecl
Sets whether every render places the piece unless the render options
leave it out (see default_on),
and returns the declaration.
Trait Implementations§
Auto Trait Implementations§
impl Forget for PieceDecl
impl Freeze for PieceDecl
impl Move for PieceDecl
impl RefUnwindSafe for PieceDecl
impl Send for PieceDecl
impl Sync for PieceDecl
impl Unpin for PieceDecl
impl UnsafeUnpin for PieceDeclwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
PhantomData<fn() -> Piece>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for PieceDecl
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