pub struct FigureLayer<'a> { /* private fields */ }Expand description
A sink, a stamp mode and who is stamping, bound together at construction.
The caller’s choice between the two stamp modes is taken here, once: no shape or fragment
this crate defines ever names a StampMode itself, since a shape has no opinion about how
it composes with the figures it draws alongside — see Shapes in
docs/model.md. The same holds for the identity: ownership is per
shape, not per cell, so it rides here rather than on Surface::stamp, and a shape is never
told which identity it draws under. FigureLayer is the only Surface this crate ships.
A layer bound by new is bound to nobody and owns nothing, which is what the
core’s own figures ask for — they are values that draw and nothing more.
Implementations§
Source§impl<'a> FigureLayer<'a>
impl<'a> FigureLayer<'a>
Sourcepub fn new(sink: &'a mut dyn StampSink, mode: StampMode) -> Self
pub fn new(sink: &'a mut dyn StampSink, mode: StampMode) -> Self
Binds sink to mode for every stamp drawn through this layer, under no identity.
Sourcepub fn stamped_by(
sink: &'a mut dyn StampSink,
mode: StampMode,
owner: ShapeId,
) -> Self
pub fn stamped_by( sink: &'a mut dyn StampSink, mode: StampMode, owner: ShapeId, ) -> Self
Binds sink to mode and to owner for every stamp drawn through this layer.
One layer per figure rather than one per stamp, which is what keeps the identity off
Surface::stamp: a figure with an identity parameter is a figure that can be drawn under
two, or under none, and the caller above is the only thing that knows which.
The identity is taken by value, which is what leaves this struct with a single lifetime:
an identity is two bytes and Copy, so a layer holds one without borrowing it, and nothing
downstream of this constructor has to keep a shape’s identity alive for the length of a
drawing.