Move primitives around
This commit is contained in:
parent
5de07073d3
commit
1ea6f74296
|
@ -2,6 +2,46 @@ use super::tim::types::Encoding;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Job {
|
||||
pub name: String,
|
||||
pub file_path: PathBuf,
|
||||
pub image_pos: ImagePosition,
|
||||
pub palette_rect: Option<PaletteRect>,
|
||||
pub encoding: Encoding,
|
||||
}
|
||||
|
||||
impl Job {
|
||||
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), encoding: Encoding) -> Job {
|
||||
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, encoding}
|
||||
}
|
||||
|
||||
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
|
||||
if file_path.is_file() {
|
||||
file_path
|
||||
}
|
||||
|
||||
else {
|
||||
let mut new_file_path = PathBuf::from(location_path);
|
||||
|
||||
new_file_path.pop();
|
||||
new_file_path.push(file_path);
|
||||
new_file_path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Project {
|
||||
pub jobs: Vec<Job>
|
||||
}
|
||||
|
||||
impl Project {
|
||||
pub fn new(jobs: Vec<Job>) -> Project {
|
||||
Project{jobs}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ImagePosition {
|
||||
pub x: u16,
|
||||
|
@ -67,43 +107,3 @@ impl std::default::Default for PaletteRect {
|
|||
PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Job {
|
||||
pub name: String,
|
||||
pub file_path: PathBuf,
|
||||
pub image_pos: ImagePosition,
|
||||
pub palette_rect: Option<PaletteRect>,
|
||||
pub encoding: Encoding,
|
||||
}
|
||||
|
||||
impl Job {
|
||||
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), encoding: Encoding) -> Job {
|
||||
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, encoding}
|
||||
}
|
||||
|
||||
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
|
||||
if file_path.is_file() {
|
||||
file_path
|
||||
}
|
||||
|
||||
else {
|
||||
let mut new_file_path = PathBuf::from(location_path);
|
||||
|
||||
new_file_path.pop();
|
||||
new_file_path.push(file_path);
|
||||
new_file_path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Project {
|
||||
pub jobs: Vec<Job>
|
||||
}
|
||||
|
||||
impl Project {
|
||||
pub fn new(jobs: Vec<Job>) -> Project {
|
||||
Project{jobs}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue