use relate_model::CypherValue;
pub(crate) struct ProcArgMeta {
pub name: &'static str,
pub description: &'static str,
pub type_str: &'static str,
pub deprecated: bool,
pub default: Option<&'static str>,
}
impl ProcArgMeta {
pub(crate) const fn new(name: &'static str, type_str: &'static str) -> Self {
Self::described(name, "", type_str)
}
pub(crate) const fn with_default(
name: &'static str,
description: &'static str,
type_str: &'static str,
default: &'static str,
) -> Self {
Self {
name,
description,
type_str,
deprecated: false,
default: Some(default),
}
}
pub(crate) const fn described(
name: &'static str,
description: &'static str,
type_str: &'static str,
) -> Self {
Self {
name,
description,
type_str,
deprecated: false,
default: None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct DeprecatedBy {
display: &'static str,
form: DeprecationForm,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DeprecationForm {
Identifier(&'static str),
Clause(&'static str),
}
impl DeprecatedBy {
pub const fn identifier(identifier: &'static str) -> Self {
Self {
display: identifier,
form: DeprecationForm::Identifier(identifier),
}
}
pub const fn clause(clause: &'static str) -> Self {
Self {
display: clause,
form: DeprecationForm::Clause(clause),
}
}
pub const fn identified(identifier: &'static str, display: &'static str) -> Self {
Self {
display,
form: DeprecationForm::Identifier(identifier),
}
}
pub fn display(self) -> &'static str {
self.display
}
pub fn form(self) -> DeprecationForm {
self.form
}
}
pub(crate) fn string_list(values: impl IntoIterator<Item = String>) -> CypherValue {
CypherValue::List(values.into_iter().map(CypherValue::Str).collect())
}