1use async_trait::async_trait;
2use serde_json::Value;
3
4use crate::{KhiveRuntime, KindHook, RuntimeError};
5
6#[derive(Debug)]
7struct SharedCreateRefusal {
8 kind: &'static str,
9 own_verb: &'static str,
10}
11
12pub fn refuse_shared_create(kind: &'static str, own_verb: &'static str) -> impl KindHook {
15 SharedCreateRefusal { kind, own_verb }
16}
17
18#[async_trait]
19impl KindHook for SharedCreateRefusal {
20 async fn prepare_create(
21 &self,
22 _runtime: &KhiveRuntime,
23 _args: &mut Value,
24 ) -> Result<(), RuntimeError> {
25 Err(RuntimeError::InvalidInput(format!(
26 "kind={} is not creatable through shared `create`, `stream.batch`, or standalone \
27 `stream.append`; only `{}` applies this kind's creation contract; use `{}` instead",
28 self.kind, self.own_verb, self.own_verb
29 )))
30 }
31}