Skip to main content

reifydb_core/interface/catalog/
procedure.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use reifydb_type::value::{constraint::TypeConstraint, sumtype::VariantRef};
5use serde::{Deserialize, Serialize};
6
7use crate::interface::catalog::id::{NamespaceId, ProcedureId};
8
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
10pub enum ProcedureTrigger {
11	/// Invoked explicitly via CALL
12	#[default]
13	Call,
14	/// Triggered by DISPATCH on an event variant
15	Event {
16		variant: VariantRef,
17	},
18	/// Invoked via CALL but dispatched to a registered native (Rust) implementation
19	NativeCall {
20		native_name: String,
21	},
22}
23
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
25pub struct Procedure {
26	pub id: ProcedureId,
27	pub namespace: NamespaceId,
28	pub name: String,
29	pub params: Vec<ProcedureParam>,
30	pub return_type: Option<TypeConstraint>,
31	/// RQL source text, compiled on load
32	pub body: String,
33	pub trigger: ProcedureTrigger,
34	/// Test procedures can only be called from test context
35	pub is_test: bool,
36}
37
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
39pub struct ProcedureParam {
40	pub name: String,
41	pub param_type: TypeConstraint,
42}