use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TagPosition {
pub tag_position: String,
pub tag_value: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EdgeValue {
pub is_open: bool,
pub edge_tag: Vec<TagPosition>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Edge {
pub tile_edge: EdgeValue,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Tile {
pub tile_id: String,
pub tile_center: String,
pub tile_edges: Vec<Edge>,
}
pub fn identify_tile(tile: &mut Tile) -> Result<Tile, Box<dyn std::error::Error>> {
let mut id_vec: Vec<char> = Vec::new();
let char_1: char = tile
.tile_center
.chars()
.into_iter()
.next()
.expect("string's empty...");
id_vec.push(char_1);
for edge in tile.tile_edges.iter() {
let is_open_bit: char = if edge.tile_edge.is_open == false {
'0'
} else {
'1'
};
id_vec.push(is_open_bit);
for tag_position in edge.tile_edge.edge_tag.iter() {
for tag_value_char in tag_position.tag_value.chars() {
id_vec.push(tag_value_char);
}
}
}
let tile_id_string: String = id_vec.into_iter().collect();
tile.tile_id = tile_id_string;
Ok(tile.clone())
}
pub mod generate {
use std::io::{stdin,stdout,Write};
pub fn custom_polygon() {
let mut side_input: String = String::new();
println!("number of sides:");
stdin().read_line(&mut side_input).expect("nope. bad string. don't like it.");
}
}