pub struct Block {
    id: usize,
    rows: usize,
    contains: (Option<usize>, Option<usize>),
    expanded: bool,
    typ: String,
    lbl: String,
    inputs: Vec<Option<String>>,
    outputs: Vec<Option<String>>,
    color: usize,
}
Expand description

This structure represents a block inside the BlockArea of a BlockFun. It stores everything required for calculating a node of the AST.

A BlockType::instanciate_block is used to create a new instance of this structure.

You usually don’t use this structure directly, but you use the position of it inside the BlockFun. The position of a block is specified by the area_id, and the x and y coordinates.

Fields

id: usize

An ID to track this block.

rows: usize

How many rows this block spans. A Block can only be 1 cell wide.

contains: (Option<usize>, Option<usize>)

Up to two sub BlockArea can be specified here by their ID.

expanded: bool

Whether the sub areas are visible/drawn.

typ: String

The type of this block. It’s just a string set by the BlockType and it should be everything that determines what this block is going to end up as in the AST.

lbl: String

The label of the block.

inputs: Vec<Option<String>>

The input ports, the index into the Vec is the row. The String is the label of the input port.

outputs: Vec<Option<String>>

The output ports, the index into the Vec is the row. The String is the label of the output port.

color: usize

The color index of this block.

Implementations

Takes the (input) port at row idx and pushed it one row further down, wrapping around at the end. If output is true, the output port at idx is shifted.

Calls f for every output port that is available. f gets passed the row index.

Returns the number of output ports of this Block.

Calls f for every input port that is available. f gets passed the row index.

Calls f for every input port that is available. f gets passed the row index.

Serializes this Block into a Value. Called by BlockArea::serialize.

Deserializes this Block from a Value. Called by BlockArea::deserialize.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.