mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
feat-webgarages-121 (#129)
### Description Closes #121 ### Please confirm - [x] I am the legal owner or represent the legal owner of all work submitted (including LLM-generated code, if any) - [x] I consent to my changes being added to this FOSS project - [x] I have confirmed that this does not add new errors or warnings with `utils/clippy.sh` - [ ] This PR used LLMs to generate some or all of the code changes Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/129
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
pub mod chat;
|
||||
pub mod vehicle_validation;
|
||||
pub mod team_selection;
|
||||
pub mod vehicle_import;
|
||||
|
||||
pub trait Plugin: Send + Sync {
|
||||
fn self_check(&self) -> bool {
|
||||
|
||||
2
rc_plugins/src/vehicle_import/mod.rs
Normal file
2
rc_plugins/src/vehicle_import/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod plugin;
|
||||
pub use plugin::{VehicleImportPlugin, VehicleImportErrorCode, VehicleImportData};
|
||||
35
rc_plugins/src/vehicle_import/plugin.rs
Normal file
35
rc_plugins/src/vehicle_import/plugin.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
#[repr(u8)]
|
||||
#[derive(Debug)]
|
||||
pub enum VehicleImportErrorCode {
|
||||
Invalid,
|
||||
Unsupported,
|
||||
UnknownCube,
|
||||
}
|
||||
|
||||
impl core::fmt::Display for VehicleImportErrorCode {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Invalid => write!(f, "Invalid/corrupt data"),
|
||||
Self::Unsupported => write!(f, "Unsupported/unrecognized data"),
|
||||
Self::UnknownCube => write!(f, "Unknown cube in data"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for VehicleImportErrorCode {}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VehicleImportData {
|
||||
pub cube_data: Vec<u8>,
|
||||
pub colour_data: Vec<u8>,
|
||||
pub vehicle_name: Option<String>,
|
||||
pub vehicle_author: Option<String>,
|
||||
}
|
||||
|
||||
pub trait VehicleImportPlugin: crate::Plugin {
|
||||
//fn supports(&self) -> Vec<String>;
|
||||
/// Preferred file extension for the raw data
|
||||
fn file_ext(&self) -> &'static str;
|
||||
fn import(&self, upload: &[u8]) -> Result<VehicleImportData, VehicleImportErrorCode>;
|
||||
fn export(&self, data: &VehicleImportData) -> Result<Vec<u8>, VehicleImportErrorCode>;
|
||||
}
|
||||
Reference in New Issue
Block a user