pub trait Function: Send + Sync {
type Input<'a>: Deserialize<'a> + Send;
type Output<'a>: Serialize + Send;
// Required methods
fn schema(&self, diags: &mut Diagnostics) -> Option<FunctionSchema>;
fn call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
params: Self::Input<'a>,
) -> Pin<Box<dyn Future<Output = Option<Self::Output<'a>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Trait for implementing a function with automatic serialization/deserialization
See also: DynamicFunction
Required Associated Types§
Sourcetype Input<'a>: Deserialize<'a> + Send
type Input<'a>: Deserialize<'a> + Send
Function Input
The input will be automatically serialized/deserialized at the border of the request.
Required Methods§
Sourcefn schema(&self, diags: &mut Diagnostics) -> Option<FunctionSchema>
fn schema(&self, diags: &mut Diagnostics) -> Option<FunctionSchema>
Sourcefn call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
params: Self::Input<'a>,
) -> Pin<Box<dyn Future<Output = Option<Self::Output<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
params: Self::Input<'a>,
) -> Pin<Box<dyn Future<Output = Option<Self::Output<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Call Function
§Arguments
diags- Diagnostics to record warnings and errors that occured when calling the functionparams- Function parameters packed into the input type
§Remarks
The return is ignored if there is an error in diagnostics.
If the return is None, an ad-hoc error is added to diagnostics.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".