1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Static metadata builders for the native platform built-ins.
//!
//! Ported from the historical procedure-pack built-in module (`StaticParameter`,
//! `StaticOutputColumn`) plus the pack registry's `parameter` / `output_column`
//! storage conversion. Keeping the `with_description` / `with_default_doc` /
//! `with_default` shape aligned preserves the native procedure metadata contract
//! while catalog rendering stays owned by the current engine.
use selene_core::db_string;
use crate::{GqlType, ProcedureDefaultValue, ProcedureOutputColumn, ProcedureParameter};
/// Static parameter metadata exposed by a built-in.
#[derive(Clone, Debug, Eq, PartialEq)]
pub(super) struct StaticParameter {
/// Parameter name.
pub(super) name: &'static str,
/// Parameter type.
pub(super) ty: GqlType,
/// Whether NULL is accepted.
pub(super) nullable: bool,
/// Human-readable parameter description.
pub(super) description: &'static str,
/// Documentation-only default value text.
pub(super) default_doc: Option<&'static str>,
/// Executable default value for omitted trailing optional arguments.
pub(super) default: Option<ProcedureDefaultValue>,
}
impl StaticParameter {
/// Construct static parameter metadata.
pub(super) const fn new(name: &'static str, ty: GqlType, nullable: bool) -> Self {
Self {
name,
ty,
nullable,
description: "",
default_doc: None,
default: None,
}
}
/// Attach a human-readable parameter description.
pub(super) const fn with_description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
/// Attach documentation-only default value text.
pub(super) const fn with_default_doc(mut self, default_doc: &'static str) -> Self {
self.default_doc = Some(default_doc);
self
}
/// Attach an executable default value.
pub(super) const fn with_default(mut self, default: ProcedureDefaultValue) -> Self {
self.default = Some(default);
self
}
/// Convert into planner-visible parameter metadata, preserving the pack's
/// `description` / `default_doc` / `default` carry-over rules.
pub(super) fn into_parameter(self) -> ProcedureParameter {
let mut result =
ProcedureParameter::new(static_db_string(self.name), self.ty, self.nullable)
.with_description(self.description);
if let Some(default_doc) = self.default_doc {
result = result.with_default_doc(default_doc);
}
if let Some(default) = self.default {
result = result.with_default(default);
}
result
}
}
/// Static output-column metadata exposed by a built-in.
#[derive(Clone, Debug, Eq, PartialEq)]
pub(super) struct StaticOutputColumn {
/// Output column name.
pub(super) name: &'static str,
/// Output column type.
pub(super) ty: GqlType,
/// Whether NULL is accepted.
pub(super) nullable: bool,
/// Human-readable output-column description.
pub(super) description: &'static str,
}
impl StaticOutputColumn {
/// Construct static output-column metadata.
pub(super) const fn new(name: &'static str, ty: GqlType) -> Self {
Self {
name,
ty,
nullable: false,
description: "",
}
}
/// Set whether this output column accepts NULL values.
pub(super) const fn with_nullable(mut self, nullable: bool) -> Self {
self.nullable = nullable;
self
}
/// Attach a human-readable output-column description.
pub(super) const fn with_description(mut self, description: &'static str) -> Self {
self.description = description;
self
}
/// Convert into planner-visible output-column metadata.
pub(super) fn into_output_column(self) -> ProcedureOutputColumn {
ProcedureOutputColumn::new(static_db_string(self.name), self.ty)
.with_nullable(self.nullable)
.with_description(self.description)
}
}
/// Construct a static built-in metadata name.
///
/// # Panics
///
/// Panics only if the name exceeds the per-string byte cap (IL013). Built-in
/// names/columns are a fixed, compile-time set of short identifiers, so this
/// never fires in practice; the native registry is built once at engine
/// startup.
fn static_db_string(value: &'static str) -> selene_core::DbString {
db_string(value).expect("static built-in metadata name fits DB string cap")
}