Setup and apply formatting
This commit is contained in:
parent
2cd702818e
commit
20bd1db1b7
5 changed files with 188 additions and 139 deletions
32
src/types.rs
32
src/types.rs
|
|
@ -6,16 +6,21 @@ use serde::{Serialize, Deserialize};
|
|||
pub struct Graph {
|
||||
pub nodes: HashMap<String, Node>,
|
||||
pub root_node: String,
|
||||
#[serde(default)] pub messages: Vec<String>,
|
||||
#[serde(skip)] pub incoming: HashMap<String, Vec<Edge>>,
|
||||
#[serde(default)]
|
||||
pub messages: Vec<String>,
|
||||
#[serde(skip)]
|
||||
pub incoming: HashMap<String, Vec<Edge>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
|
||||
pub struct Node {
|
||||
pub text: String,
|
||||
#[serde(default)] pub title: String,
|
||||
#[serde(default)] pub links: Vec<String>,
|
||||
#[serde(default)] pub id: String,
|
||||
#[serde(default)]
|
||||
pub title: String,
|
||||
#[serde(default)]
|
||||
pub links: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub id: String,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub connections: Option<Vec<Edge>>,
|
||||
|
|
@ -24,9 +29,12 @@ pub struct Node {
|
|||
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
|
||||
pub struct Edge {
|
||||
pub to: String,
|
||||
#[serde(default)] pub anchor: String,
|
||||
#[serde(default)] pub from: String,
|
||||
#[serde(default)] pub detached: bool,
|
||||
#[serde(default)]
|
||||
pub anchor: String,
|
||||
#[serde(default)]
|
||||
pub from: String,
|
||||
#[serde(default)]
|
||||
pub detached: bool,
|
||||
}
|
||||
|
||||
impl Graph {
|
||||
|
|
@ -35,8 +43,10 @@ impl Graph {
|
|||
nodes: HashMap::new(),
|
||||
root_node: "VoidNode".to_string(),
|
||||
incoming: HashMap::new(),
|
||||
messages: vec![message
|
||||
.unwrap_or("This graph is empty or in error".to_string())],
|
||||
messages: vec![
|
||||
message
|
||||
.unwrap_or("This graph is empty or in error".to_string()),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +62,7 @@ impl Node {
|
|||
title: "Pure Void".to_string(),
|
||||
text: match message {
|
||||
Some(s) => s,
|
||||
None => "Node is empty, missing or wasn't found.".to_string()
|
||||
None => "Node is empty, missing or wasn't found.".to_string(),
|
||||
},
|
||||
connections: None,
|
||||
links: vec![],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue