use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NodeLabel {
File,
Module,
Function,
Behaviour,
Callback,
ApiEndpoint,
ExternalApi,
}
impl fmt::Display for NodeLabel {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
NodeLabel::File => "File",
NodeLabel::Module => "Module",
NodeLabel::Function => "Function",
NodeLabel::Behaviour => "Behaviour",
NodeLabel::Callback => "Callback",
NodeLabel::ApiEndpoint => "ApiEndpoint",
NodeLabel::ExternalApi => "ExternalApi",
};
f.write_str(s)
}
}
pub mod props {
pub const PATH: &str = "path";
pub const LANGUAGE: &str = "language";
pub const FRAMEWORK: &str = "framework";
pub const PROJECT_NAME: &str = "project_name";
pub const NAME: &str = "name";
pub const FQN: &str = "fqn";
pub const ARITY: &str = "arity";
pub const RETURN_TYPE: &str = "return_type";
pub const PARAM_COUNT: &str = "param_count";
pub const PARAM_TYPES: &str = "param_types";
pub const OPTIONAL: &str = "optional";
pub const METHOD: &str = "method";
pub const PATH_TEMPLATE: &str = "path";
pub const PROTOCOL: &str = "protocol";
pub const BASE_URL: &str = "base_url";
pub const PROVIDER: &str = "provider";
pub const SERVICE: &str = "service";
pub const CODE_BYTES: &str = "code_bytes";
}
#[derive(Debug, Clone)]
pub struct FileNode<'a> {
pub path: &'a str,
pub language: &'a str,
pub framework: Option<&'a str>,
pub project_name: Option<&'a str>,
}
#[derive(Debug, Clone)]
pub struct ModuleNode<'a> {
pub name: &'a str,
pub path: &'a str,
pub language: &'a str,
pub framework: Option<&'a str>,
pub project_name: Option<&'a str>,
}
#[derive(Debug, Clone)]
pub struct FunctionNode<'a> {
pub name: &'a str,
pub fqn: &'a str,
pub path: &'a str,
pub language: &'a str,
pub framework: Option<&'a str>,
pub project_name: Option<&'a str>,
pub arity: Option<u32>,
pub return_type: Option<&'a str>,
pub param_count: Option<u32>,
pub param_types: Option<&'a [&'a str]>,
}
#[derive(Debug, Clone)]
pub struct BehaviourNode<'a> {
pub name: &'a str,
pub path: Option<&'a str>,
pub language: Option<&'a str>,
pub project_name: Option<&'a str>,
}
#[derive(Debug, Clone)]
pub struct CallbackNode<'a> {
pub name: &'a str,
pub fqn: &'a str,
pub arity: u32,
pub optional: bool,
pub language: Option<&'a str>,
pub project_name: Option<&'a str>,
}
#[derive(Debug, Clone)]
pub struct ApiEndpointNode<'a> {
pub methods: &'a [&'a str],
pub path: &'a str,
pub protocol: Option<&'a str>,
pub framework: Option<&'a str>,
pub project_name: Option<&'a str>,
}
#[derive(Debug, Clone)]
pub struct ExternalApiNode<'a> {
pub name: &'a str,
pub base_url: Option<&'a str>,
pub protocol: Option<&'a str>,
pub provider: Option<&'a str>,
pub service: Option<&'a str>,
}