Skip to main content

Command

Enum Command 

Source
pub enum Command {
Show 18 variants Move { id: ShapeId, by: Delta, }, Resize { id: ShapeId, by: Delta, }, RotateLine { id: ShapeId, }, SetStroke { id: ShapeId, stroke: Stroke, }, SetText { id: ShapeId, text: Option<Text>, }, InvertTerminals { id: ShapeId, }, MoveEndpoint { id: ShapeId, end: End, by: Delta, out: i16, }, ResetEndpoint { id: ShapeId, end: End, }, SetEndpointTerminal { id: ShapeId, end: End, terminal: Terminal, }, DetachEndpoint { id: ShapeId, end: End, }, SetEndpointLeaving { id: ShapeId, end: End, leaving: Direction, }, Hang { id: ShapeId, end: End, target: ShapeId, anchor: Anchor, }, Forward { id: ShapeId, }, Backward { id: ShapeId, }, ToFront { id: ShapeId, }, ToBack { id: ShapeId, }, Add { shape: Shape, }, Remove { id: ShapeId, },
}
Expand description

One thing a caller means to do to a diagram.

It carries the meaning and not the finished figure, and each one says which of the diagram’s seven operations it becomes. Replace(ShapeId, Shape) would restate the diagram’s own operation and throw away what the caller knew — a delta is what a person reading a list of these recognizes, and what a line of a script has to be written in either way — and the decision of which operation a meaning becomes is the work of this layer rather than of every caller that has one.

The set is open and a command added to it is additive. A session already does whatever a command says, so one more meaning is one more arm here and nothing else. The set below is what the callers so far needed and is no promise that its size is final.

The identities are compared by value, so one issued by another diagram is a well-formed value matching nothing here — the same answer the diagram gives everything that names a figure it does not hold. A command that changes nothing is not a step (#285): the session records one only for the diagram a command leaves, so one naming a figure the diagram does not hold, and one whose change gives the figure back, leave the history where it was. See Session and §5 of the model.

Variants§

§

Move

The figure goes by, along each axis.

Fields

§id: ShapeId

The figure to move.

§by: Delta

How far, along each screen axis. Negative amounts move against it.

§

Resize

The figure becomes so much wider and taller, or a line longer or shorter along its orientation.

Fields

§id: ShapeId

The figure to resize.

§by: Delta

How much the size changes along screen axes: for a box dx is width and dy is height; for a line the component along its orientation changes its length.

§

RotateLine

The line’s orientation is toggled between horizontal and vertical.

Fields

§id: ShapeId

The line whose orientation is being toggled.

§

SetStroke

The figure’s stroke is replaced with stroke.

Fields

§id: ShapeId

The figure whose stroke is being set.

§stroke: Stroke

The stroke to apply.

§

SetText

The box’s text is replaced with text, or taken out when it is None.

Fields

§id: ShapeId

The box whose text is being set.

§text: Option<Text>

The block to store, or None for no text at all.

§

InvertTerminals

The connector’s terminals are swapped.

Fields

§id: ShapeId

The connector whose terminals are being inverted.

§

MoveEndpoint

The connector’s endpoint specified by end goes by and adjusts standoff by out.

Fields

§id: ShapeId

The connector whose endpoint is being moved.

§end: End

Which endpoint is targeted (From or To).

§by: Delta

How far to move the endpoint along screen axes.

§out: i16

How far outward to adjust standoff.

§

ResetEndpoint

The connector’s endpoint specified by end has its offset and standoff reset to zero.

Fields

§id: ShapeId

The connector whose endpoint is being reset.

§end: End

Which endpoint is targeted (From or To).

§

SetEndpointTerminal

The connector’s endpoint specified by end has its terminal replaced by terminal.

Fields

§id: ShapeId

The connector whose endpoint terminal is being set.

§end: End

Which endpoint is targeted (From or To).

§terminal: Terminal

The terminal style to apply.

§

DetachEndpoint

The connector’s endpoint specified by end is detached into an absolute canvas position.

Fields

§id: ShapeId

The connector whose endpoint is being detached.

§end: End

Which endpoint is targeted (From or To).

§

SetEndpointLeaving

The connector’s detached endpoint specified by end has its departure direction set to leaving.

Fields

§id: ShapeId

The connector whose endpoint leaving direction is being set.

§end: End

Which endpoint is targeted (From or To).

§leaving: Direction

The direction the connector leaves the endpoint in.

§

Hang

One end of a connector hangs from one of target’s four sides.

Fields

§id: ShapeId

The connector whose end is being hung.

§end: End

Which endpoint hangs (From or To).

§target: ShapeId

The figure the end hangs from.

§anchor: Anchor

Which of that figure’s four sides it hangs from.

§

Forward

The figure goes one place toward the front of the order.

Fields

§id: ShapeId

The figure to move forward.

§

Backward

The figure goes one place toward the back of the order.

Fields

§id: ShapeId

The figure to move backward.

§

ToFront

The figure goes to the front of the order.

Fields

§id: ShapeId

The figure to move to the front.

§

ToBack

The figure goes to the back of the order.

Fields

§id: ShapeId

The figure to move to the back.

§

Add

The figure is added to the front of the drawing order.

Fields

§shape: Shape

The figure to add.

§

Remove

The figure is taken out.

Fields

§id: ShapeId

The figure to take out.

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Command

Source§

impl PartialEq for Command

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Command

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.