added cartridge dto
This commit is contained in:
parent
203e0835e3
commit
3e7f2a5487
@ -18,6 +18,31 @@ pub struct Cartridge {
|
|||||||
pub assets_path: Option<PathBuf>,
|
pub assets_path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct CartridgeDTO {
|
||||||
|
pub app_id: u32,
|
||||||
|
pub title: String,
|
||||||
|
pub app_version: String,
|
||||||
|
pub app_mode: AppMode,
|
||||||
|
pub entrypoint: String,
|
||||||
|
pub program: Vec<u8>,
|
||||||
|
pub assets_path: Option<PathBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CartridgeDTO> for Cartridge {
|
||||||
|
fn from(dto: CartridgeDTO) -> Self {
|
||||||
|
Self {
|
||||||
|
app_id: dto.app_id,
|
||||||
|
title: dto.title,
|
||||||
|
app_version: dto.app_version,
|
||||||
|
app_mode: dto.app_mode,
|
||||||
|
entrypoint: dto.entrypoint,
|
||||||
|
program: dto.program,
|
||||||
|
assets_path: dto.assets_path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CartridgeError {
|
pub enum CartridgeError {
|
||||||
NotFound,
|
NotFound,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use crate::model::cartridge::{Cartridge, CartridgeError, CartridgeManifest};
|
use crate::model::cartridge::{Cartridge, CartridgeDTO, CartridgeError, CartridgeManifest};
|
||||||
|
|
||||||
pub struct CartridgeLoader;
|
pub struct CartridgeLoader;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ impl DirectoryCartridgeLoader {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Cartridge {
|
let dto = CartridgeDTO {
|
||||||
app_id: manifest.app_id,
|
app_id: manifest.app_id,
|
||||||
title: manifest.title,
|
title: manifest.title,
|
||||||
app_version: manifest.app_version,
|
app_version: manifest.app_version,
|
||||||
@ -63,7 +63,9 @@ impl DirectoryCartridgeLoader {
|
|||||||
entrypoint: manifest.entrypoint,
|
entrypoint: manifest.entrypoint,
|
||||||
program,
|
program,
|
||||||
assets_path,
|
assets_path,
|
||||||
})
|
};
|
||||||
|
|
||||||
|
Ok(Cartridge::from(dto))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ mod cartridge_loader;
|
|||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
pub use button::Button;
|
pub use button::Button;
|
||||||
pub use cartridge::{AppMode, Cartridge, CartridgeError};
|
pub use cartridge::{AppMode, Cartridge, CartridgeDTO, CartridgeError};
|
||||||
pub use cartridge_loader::{CartridgeLoader, DirectoryCartridgeLoader, PackedCartridgeLoader};
|
pub use cartridge_loader::{CartridgeLoader, DirectoryCartridgeLoader, PackedCartridgeLoader};
|
||||||
pub use color::Color;
|
pub use color::Color;
|
||||||
pub use sample::Sample;
|
pub use sample::Sample;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user