mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
wip
This commit is contained in:
1 parent
28ccde8394
commit
13a12480cd
1 file changed
+42
-15
+42
-15
@@ -186,6 +186,9 @@ impl RawRequest {
|
||||
pub fn add_pano_node(&mut self, node: PanoNode) {
|
||||
self.object.metadata.nodes.insert(node.id.clone(), NodeValue::Pano(node));
|
||||
}
|
||||
pub fn add_world_node(&mut self, node: WorldNode) {
|
||||
self.object.metadata.nodes.insert(node.id.clone(), NodeValue::World(node));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -194,6 +197,7 @@ impl RawRequest {
|
||||
enum NodeValue {
|
||||
ImageInput(ImageInputNode),
|
||||
Pano(PanoNode),
|
||||
World(WorldNode),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
@@ -277,20 +281,42 @@ impl PanoNode {
|
||||
}
|
||||
}
|
||||
|
||||
//impl Default for ImageInputNode {
|
||||
// fn default() -> Self {
|
||||
// Self {
|
||||
// id: "".to_string(),
|
||||
// r#type: TypeInput::Input,
|
||||
// parent_id: None,
|
||||
// source: ImageInputNodeSource {
|
||||
// r#type: TypeInput::Input,
|
||||
// image_url: "".to_string()
|
||||
// },
|
||||
// created_at: 0,
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#[derive(Serialize, Default)]
|
||||
struct WorldNode {
|
||||
pub id: String,
|
||||
pub r#type: TypeWorld,
|
||||
#[serde(rename = "parentId")]
|
||||
pub parent_id: Option<String>,
|
||||
pub source: WorldNodeSource,
|
||||
#[serde(rename = "createdAt")]
|
||||
pub created_at: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
struct WorldNodeSource {
|
||||
pub r#type: TypeGenerateWorld,
|
||||
pub world_id: StatusPending,
|
||||
pub posed_cubemaps_url: String,
|
||||
pub minimap_url: String,
|
||||
pub minimap_metadata: String,
|
||||
pub status: StatusPending,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default)]
|
||||
enum TypeWorld {
|
||||
#[serde(rename = "world")]
|
||||
#[default]
|
||||
World
|
||||
}
|
||||
|
||||
impl WorldNode {
|
||||
pub fn with_id(id: &str) -> Self{
|
||||
Self {
|
||||
id: id.to_string(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -300,7 +326,7 @@ struct RawResponse {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::api::requests::objects::update_run_object_with_upload::{ImageInputNode, PanoNode, PanoNodeSource, RawRequest};
|
||||
use crate::api::requests::objects::update_run_object_with_upload::{ImageInputNode, PanoNode, PanoNodeSource, RawRequest, WorldNode};
|
||||
|
||||
#[test]
|
||||
fn request_default() {
|
||||
@@ -316,6 +342,7 @@ mod tests {
|
||||
|
||||
request.add_image_input_node(ImageInputNode::with_id("foo_id"));
|
||||
request.add_pano_node(PanoNode::with_id("bar_id"));
|
||||
request.add_world_node(WorldNode::with_id("baz_id"));
|
||||
|
||||
let json = serde_json::to_string_pretty(&request).unwrap();
|
||||
println!("{}", json);
|
||||
|
||||
Reference in new issue
Block a user