pub struct BlockChain {
    area_id: usize,
    blocks: HashSet<(i64, i64)>,
    sources: HashSet<(i64, i64)>,
    sinks: HashSet<(i64, i64)>,
    load: Vec<(Box<Block>, i64, i64)>,
}
Expand description

Represents a connected collection of blocks. Is created by BlockFun::retrieve_block_chain_at or BlockArea::chain_at.

After creating a BlockChain structure you can decide to clone the blocks from the BlockArea with BlockChain::clone_load or remove the blocks from the BlockArea and store them inside this BlockChain via BlockChain::remove_load.

The original positions of the loaded blocks is stored too. If you want to move the whole chain in the coordinate system to the upper left most corner, you can use BlockChain::normalize_load_pos.

Fields

area_id: usize

The area ID this BlockChain was created from.

blocks: HashSet<(i64, i64)>

Stores the positions of the blocks of the chain inside the BlockArea.

sources: HashSet<(i64, i64)>

Stores the positions of blocks that only have output ports.

sinks: HashSet<(i64, i64)>

Stores the positions of blocks that only have input ports.

load: Vec<(Box<Block>, i64, i64)>

This field stores loaded blocks from the BlockArea into this BlockChain for inserting or analyzing them.

Stores the blocks themself, with their position in the BlockArea, which can be normalized (moved to the upper left) with BlockChain::normalize_load_pos.

The blocks in this Vec are stored in sorted order. They are stored in ascending order of their x coordinate, and for the same x coordinate in ascending order of their y coordinate.

Implementations

Normalizes the position of all loaded blocks and returns the original top left most position of the chain.

Trait Implementations

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