1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add factory upload support to trait, make client handle rejections gracefully #6

This commit is contained in:
NG (Graham)
2025-05-18 21:52:03 -04:00
parent fd75dba80e
commit a0dba39475
12 changed files with 196 additions and 12 deletions

View File

@@ -146,4 +146,9 @@ impl crate::VehicleFactoryAdapter for ArcAdapter {
log::debug!("Search vehicles returned {} results", infos.len());
Ok(infos)
}
async fn upload(&self, _vehicle: crate::VehicleUploadInfo) -> Result<bool, Box<dyn std::error::Error>> {
log::info!("Arc adapter does not support uploading factory vehicles");
Ok(false)
}
}

View File

@@ -1,4 +1,4 @@
pub mod arc;
mod traits;
pub use traits::{VehicleFactoryAdapter, VehicleInfo, VehicleQueryInfo};
pub use traits::{VehicleFactoryAdapter, VehicleInfo, VehicleQueryInfo, VehicleUploadInfo};

View File

@@ -2,6 +2,7 @@
pub trait VehicleFactoryAdapter: Send + Sync + 'static {
async fn vehicle(&self, id: u32) -> Result<Option<(VehicleInfo, VehicleQueryInfo)>, Box<dyn std::error::Error>>;
async fn list(&self, query: libfj::robocraft::ListQuery) -> Result<Vec<VehicleQueryInfo>, Box<dyn std::error::Error>>;
async fn upload(&self, vehicle: VehicleUploadInfo) -> Result<bool, Box<dyn std::error::Error>>;
}
#[derive(Debug, Clone)]
@@ -50,3 +51,17 @@ pub struct VehicleQueryInfo {
pub cosmetic_rating: f64,
pub cube_amounts: std::collections::HashMap<u32, u32>,
}
#[derive(Debug)]
pub struct VehicleUploadInfo {
pub name: String,
pub description: String,
pub thumbnail: Vec<u8>,
pub added_by: String,
pub added_by_display_name: String,
pub cpu: u32,
pub total_robot_ranking: u32,
pub cube_data: Vec<u8>,
pub colour_data: Vec<u8>,
pub build_version: String,
}