1
0
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:
NG (Graham)
2026-06-15 01:02:52 +00:00
committed by NGnius
parent a222745841
commit d2626bb47f
40 changed files with 4012 additions and 282 deletions

View File

@@ -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 {

View File

@@ -0,0 +1,2 @@
mod plugin;
pub use plugin::{VehicleImportPlugin, VehicleImportErrorCode, VehicleImportData};

View 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>;
}