1#![allow(clippy::type_complexity)]23use crate::gc::TraceBox;4use crate::{error::Result, Val};5use gcmodule::Trace;6use jrsonnet_parser::ParamsDesc;7use std::fmt::Debug;8use std::path::Path;9use std::rc::Rc;1011#[deprecated(note = "Use builtins instead")]12pub trait NativeCallbackHandler: Trace {13 fn call(&self, from: Rc<Path>, args: &[Val]) -> Result<Val>;14}1516#[derive(Trace)]17pub struct NativeCallback {18 pub params: ParamsDesc,19 handler: TraceBox<dyn NativeCallbackHandler>,20}21impl NativeCallback {22 pub fn new(params: ParamsDesc, handler: TraceBox<dyn NativeCallbackHandler>) -> Self {23 Self { params, handler }24 }25 pub fn call(&self, caller: Rc<Path>, args: &[Val]) -> Result<Val> {26 self.handler.call(caller, args)27 }28}29impl Debug for NativeCallback {30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {31 f.debug_struct("NativeCallback").finish()32 }33}