pub trait ScriptClient {
// Required method
fn execute<'life0, 'async_trait, T, P>(
&'life0 self,
script_name: impl 'async_trait + Into<String> + Send,
parameter: Option<P>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned,
P: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn execute_without_parameter<'life0, 'life1, 'async_trait, T>(
&'life0 self,
script_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned,
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Required Methods§
Sourcefn execute<'life0, 'async_trait, T, P>(
&'life0 self,
script_name: impl 'async_trait + Into<String> + Send,
parameter: Option<P>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
P: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait, T, P>(
&'life0 self,
script_name: impl 'async_trait + Into<String> + Send,
parameter: Option<P>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
P: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
Executes a script with an optional parameter.
Parameters must be serializable and results deserializable through serde
.
§Examples
use fm_script_client::{ScriptClient, Connection, odata_api::ODataApiScriptClient};
use serde::Deserialize;
#[derive(Deserialize)]
struct Result {
success: bool,
}
#[tokio::main]
async fn main() {
let connection: Connection = "http://foo:bar@localhost:9999/test"
.try_into()
.unwrap();
let client = ODataApiScriptClient::new(connection);
let result: Result = client.execute("my_script", Some("parameter")).await.unwrap();
assert_eq!(result.success, true);
}
Provided Methods§
Sourcefn execute_without_parameter<'life0, 'life1, 'async_trait, T>(
&'life0 self,
script_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_without_parameter<'life0, 'life1, 'async_trait, T>(
&'life0 self,
script_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Convenience method to execute a script without a parameter.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.