Struct Project

Source
pub struct Project {
    pub project_file_path: Option<String>,
    pub project_dir: Option<String>,
    pub name: String,
    pub bg_color: String,
    pub json_version: String,
    pub default_pivot_x: f64,
    pub default_pivot_y: f64,
    pub levels: Vec<Level>,
}

Fields§

§project_file_path: Option<String>

Contains the full path to the project JSON, as provided to the macro (using slashes)

§project_dir: Option<String>

Contains the directory of the project JSON (using slashes, no trailing slash)

§name: String

Project name

§bg_color: String

Project background color as hex (e.g. #FFFFFF)

§json_version: String§default_pivot_x: f64§default_pivot_y: f64§levels: Vec<Level>

Implementations§

Source§

impl Project

Source

pub fn parse_json(json: String) -> Result<Self, Error>

Examples found in repository?
examples/iter_render_data.rs (line 18)
8fn parse_file(file_name: &str) -> Project {
9    let mut file_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
10    file_path.push("examples");
11    file_path.push(file_name);
12    file_path.set_extension("json");
13
14    let mut file = File::open(file_path).unwrap();
15    let mut contents = String::new();
16    file.read_to_string(&mut contents).unwrap();
17
18    Project::parse_json(contents).unwrap()
19}
More examples
Hide additional examples
examples/parse_sample.rs (line 17)
7fn parse_file(file_name: &str) -> Project {
8    let mut file_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
9    file_path.push("examples");
10    file_path.push(file_name);
11    file_path.set_extension("json");
12
13    let mut file = File::open(file_path).unwrap();
14    let mut contents = String::new();
15    file.read_to_string(&mut contents).unwrap();
16
17    Project::parse_json(contents).unwrap()
18}
examples/render_data.rs (line 18)
8fn parse_file(file_name: &str) -> Project {
9    let mut file_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
10    file_path.push("examples");
11    file_path.push(file_name);
12    file_path.set_extension("json");
13
14    let mut file = File::open(file_path).unwrap();
15    let mut contents = String::new();
16    file.read_to_string(&mut contents).unwrap();
17
18    Project::parse_json(contents).unwrap()
19}
examples/parse_empty.rs (line 17)
7fn parse_file(file_name: &str) {
8    let mut file_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
9    file_path.push("examples");
10    file_path.push(file_name);
11    file_path.set_extension("json");
12
13    let mut file = File::open(file_path).unwrap();
14    let mut contents = String::new();
15    file.read_to_string(&mut contents).unwrap();
16
17    println!("{:?}", Project::parse_json(contents).unwrap());
18}

Trait Implementations§

Source§

impl Debug for Project

Source§

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

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

impl<'de> Deserialize<'de> for Project

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ToRenderGrid for Project

Source§

fn to_merged_render_grid(&self, level: usize) -> Result<RenderGrid, Error>

Creates a render grid with the layers merged down into a single layer. Excludes entity layers and intgrid layers but includes autotile and tile layers

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,