2023-02-17 12:33:16 +01:00
|
|
|
use crate::functions::FormatTypeFuncs;
|
|
|
|
|
|
|
|
use super::functions::format_name;
|
|
|
|
|
|
|
|
pub struct FormatTypeFunc;
|
|
|
|
|
|
|
|
impl FormatTypeFuncs for FormatTypeFunc {
|
2023-02-19 17:21:40 +01:00
|
|
|
fn format_kind_list(&self, representation: &str, _input: bool, _immutable: bool) -> String {
|
2023-02-17 12:33:16 +01:00
|
|
|
format!("Vec<{}>", representation)
|
|
|
|
}
|
|
|
|
|
2023-02-19 17:21:40 +01:00
|
|
|
fn format_kind_scalar_string(&self, representation: &str, input: bool) -> String {
|
2023-02-17 12:33:16 +01:00
|
|
|
let mut rep = representation.to_string();
|
2023-02-19 17:21:40 +01:00
|
|
|
if input {
|
|
|
|
rep.push_str("impl Into<String>");
|
|
|
|
} else {
|
|
|
|
rep.push_str("String");
|
|
|
|
}
|
2023-02-17 12:33:16 +01:00
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_scalar_int(&self, representation: &str) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str("isize");
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_scalar_float(&self, representation: &str) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str("float");
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_scalar_boolean(&self, representation: &str) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str("bool");
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_scalar_default(
|
|
|
|
&self,
|
|
|
|
representation: &str,
|
|
|
|
ref_name: &str,
|
2023-02-17 17:51:39 +01:00
|
|
|
_input: bool,
|
2023-02-17 12:33:16 +01:00
|
|
|
) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str(&format_name(ref_name));
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_object(&self, representation: &str, ref_name: &str) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str(&format_name(ref_name));
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_input_object(&self, representation: &str, ref_name: &str) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str(&format_name(ref_name));
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
|
|
|
|
fn format_kind_enum(&self, representation: &str, ref_name: &str) -> String {
|
|
|
|
let mut rep = representation.to_string();
|
|
|
|
rep.push_str(&format_name(ref_name));
|
|
|
|
rep
|
|
|
|
}
|
|
|
|
}
|