Skip to main content

FigureLayer

Struct FigureLayer 

Source
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>

Source

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.

Source

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.

Trait Implementations§

Source§

impl Surface for FigureLayer<'_>

Source§

fn stamp(&mut self, at: Pos, cell: Cell)

Writes cell at the absolute position at.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FigureLayer<'a>

§

impl<'a> !Send for FigureLayer<'a>

§

impl<'a> !Sync for FigureLayer<'a>

§

impl<'a> !UnwindSafe for FigureLayer<'a>

§

impl<'a> Forget for FigureLayer<'a>

§

impl<'a> Freeze for FigureLayer<'a>

§

impl<'a> Unpin for FigureLayer<'a>

§

impl<'a> UnsafeUnpin for FigureLayer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.