pub struct BlockArea {
blocks: HashMap<(i64, i64), Box<Block>>,
origin_map: HashMap<(i64, i64), (i64, i64)>,
size: (usize, usize),
auto_shrink: bool,
header: String,
}
Fields
blocks: HashMap<(i64, i64), Box<Block>>
origin_map: HashMap<(i64, i64), (i64, i64)>
size: (usize, usize)
auto_shrink: bool
header: String
Implementations
sourceimpl BlockArea
impl BlockArea
fn new(w: usize, h: usize) -> Self
pub fn set_header(&mut self, header: String)
pub fn set_auto_shrink(&mut self, shrink: bool)
pub fn auto_shrink(&self) -> bool
pub fn chain_at(&self, x: i64, y: i64) -> Option<Box<BlockChain>>
pub fn find_last_unconnected_output(&self) -> Option<(i64, i64, String)>
sourcepub fn collect_sinks(&self) -> Vec<(i64, i64, Option<usize>)>
pub fn collect_sinks(&self) -> Vec<(i64, i64, Option<usize>)>
Collects the sinks in this area. It returns a list of Block positions inside the area. For unconnected outputs, which are also evaluated and returned as possible last value of an BlockArea, the output row is also given.
The result is sorted so, that the bottom right most element is the first one in the result list.
fn ref_at(&self, x: i64, y: i64) -> Option<&Block>
fn ref_at_origin(&self, x: i64, y: i64) -> Option<(&Block, i64, i64)>
fn ref_mut_at(&mut self, x: i64, y: i64) -> Option<&mut Block>
fn ref_mut_at_origin(&mut self, x: i64, y: i64) -> Option<(&mut Block, i64, i64)>
fn find_port_at(
&self,
x: i64,
y: i64,
expect_output: bool
) -> Option<(&Block, i64, i64, usize)>
fn set_blocks_from(&mut self, list: Vec<(Box<Block>, i64, i64)>)
fn set_block_at(&mut self, x: i64, y: i64, block: Box<Block>)
fn remove_at(&mut self, x: i64, y: i64) -> Option<(Box<Block>, i64, i64)>
fn set_size(&mut self, w: usize, h: usize)
fn get_direct_sub_areas(&self, out: &mut Vec<usize>)
sourcefn resolve_size<F: Fn(usize) -> (usize, usize)>(
&self,
resolve_sub_areas: F
) -> (usize, usize)
fn resolve_size<F: Fn(usize) -> (usize, usize)>(
&self,
resolve_sub_areas: F
) -> (usize, usize)
Calculates only the size of the area in the +x/+y quadrant. The negative areas are not counted in.
fn update_origin_map(&mut self)
fn check_space_at(&self, x: i64, y: i64, rows: usize) -> bool
sourcepub fn serialize(&self) -> Value
pub fn serialize(&self) -> Value
Serializes this BlockArea to a JSON Value. Usually called by BlockFunSnapshot::serialize.
sourcepub fn deserialize(v: &Value) -> Result<Box<BlockArea>, Error>
pub fn deserialize(v: &Value) -> Result<Box<BlockArea>, Error>
Deserializes a from a JSON Value. Usually called by BlockFunSnapshot::deserialize.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BlockArea
impl Send for BlockArea
impl Sync for BlockArea
impl Unpin for BlockArea
impl UnwindSafe for BlockArea
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more