1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::sync::{Arc, Mutex};
use crate::{
error::Error, interface_implementation::InterfaceImplementations,
resolution::uri_resolution_context::UriResolutionContext, uri::Uri,
};
/// Defines an object capable of invoking on URIs
pub trait Invoker: Send + Sync {
/// Invokes a method on a given URI with optional arguments and environment.
/// The method returns a Result containing either the msgpcack buffer of the response or an Error.
///
/// # Arguments
///
/// * `uri` - A reference to the Uri to invoke the method on.
/// * `method` - The name of the method to invoke.
/// * `args` - Optional msgpack buffer representing the arguments to the method.
/// * `env` - Optional msgpack buffer representing the environment for the method.
/// * `resolution_context` - Optional resolution context of invocation.
fn invoke_raw(
&self,
uri: &Uri,
method: &str,
args: Option<&[u8]>,
env: Option<&[u8]>,
resolution_context: Option<Arc<Mutex<UriResolutionContext>>>,
) -> Result<Vec<u8>, Error>;
/// Returns a list of Uris that this invoker can handle.
///
/// # Arguments
///
/// * `uri` - A reference to the Uri to get the implementations for.
fn get_implementations(&self, uri: &Uri) -> Result<Vec<Uri>, Error>;
/// Returns a list of interfaces that this invoker can handle.
fn get_interfaces(&self) -> Option<InterfaceImplementations>;
/// Returns the environment for a given Uri.
///
/// # Arguments
///
/// * `uri` - A reference to the Uri to get the environment for.
fn get_env_by_uri(&self, uri: &Uri) -> Option<Vec<u8>>;
}