pub struct FreightProxy {
pub freight: Box<dyn Freight>,
pub lib: Rc<Library>,
pub name: &'static str,
pub version: &'static str,
}
Expand description
A structure, that contains a Freight object and is used to import and use it safely
This structure is a Freight
trait implementor and
FreightRegistrar
trait implementor. It provides
FreightProxy::load
function that is used to build the
FreightProxy
from a library path
To learn more about the functions you may call on the
FreightProxy
, see Freight
trait documentation
§Example
let mut my_f_proxy: FreightProxy = unsafe{
FreightProxy::load("/bin/libtest_plug.so").expect("fail")
};
println!("{}, {}", my_f_proxy.name, my_f_proxy.version);
let fnlist: Vec<Function> = my_f_proxy.get_function_list();
for func in fnlist {
println!("{}, {}", func.name, func.number);
}
Fields§
§freight: Box<dyn Freight>
Imported freight, solely for internal purposes
lib: Rc<Library>
Lib this freight was imported from to make sure this structure does not outlive the library it was imported from
name: &'static str
Imported freights name as a static string
version: &'static str
Imported freights version as a static string
Implementations§
Source§impl FreightProxy
Functions, needed to configure FreightProxy
structure
initially
impl FreightProxy
Functions, needed to configure FreightProxy
structure
initially
Sourcepub unsafe fn load(lib_path: &str) -> Result<FreightProxy, RuntimeError>
pub unsafe fn load(lib_path: &str) -> Result<FreightProxy, RuntimeError>
Function, used to build a FreightProxy
object from a
library path
Trait Implementations§
Source§impl Freight for FreightProxy
impl Freight for FreightProxy
Source§fn call_function(
&mut self,
function_number: u64,
args: Vec<&mut Box<dyn Any>>,
) -> Result<Box<dyn Any>, RuntimeError>
fn call_function( &mut self, function_number: u64, args: Vec<&mut Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeError>
Function that is used to call proxy the calls from the
outside of a plugin to the internal functions and must
implement function calling, by its number arguments,
contained inside of
Vec<Box<dyn Any>>
and must return
either a Box<dyn Any>
representing the returned value
or a RuntimeError
Source§fn init(
&mut self,
limitations: &Option<Vec<Limitation>>,
) -> Vec<InterplugRequest>
fn init( &mut self, limitations: &Option<Vec<Limitation>>, ) -> Vec<InterplugRequest>
Function that is ran when importing the plugin, which
may be reimplememented in a plugin if it needs to set up
some things before doing any other actions Read more
Source§fn update_limitations(&mut self, limitations: &Vec<Limitation>)
fn update_limitations(&mut self, limitations: &Vec<Limitation>)
Function that updates system limitations
Source§fn interplug_provide(
&mut self,
request: InterplugRequest,
freight_proxy: Rc<FreightProxy>,
)
fn interplug_provide( &mut self, request: InterplugRequest, freight_proxy: Rc<FreightProxy>, )
Function that replies to the interplugin request by
providing the requested plugin
Source§fn interplug_deny(&mut self, request: InterplugRequest)
fn interplug_deny(&mut self, request: InterplugRequest)
Function that replies to the interplugin request by
by informing it that the request was denied
Source§fn get_function_list(&mut self) -> Vec<Function>
fn get_function_list(&mut self) -> Vec<Function>
Function that is used to provide information about internal
functions of a plugin to the program using it, so it can
choose the function it needs either by its name, argument
types, return type or all of the above
Source§fn get_type_list(&mut self) -> Vec<Type>
fn get_type_list(&mut self) -> Vec<Type>
Function that is used to provide information about
non standard types, a function from this plugin might take
as an argument or return, so that the program using the
plugin can take such non-standard objects from one
function implemented in this plugin and pass it on into
another function in this plugin Read more
Source§fn get_operator_list(&mut self) -> Vec<Function>
fn get_operator_list(&mut self) -> Vec<Function>
Function that is used to provide information about internal
functions of a plugin that are named after binary operators
and should be treated as such. These functions have to
always get exactly two arguments and they are called by the
same function that calls any function
Freight::call_function
Source§impl FreightRegistrar for FreightProxy
impl FreightRegistrar for FreightProxy
Source§fn register_freight(&mut self, freight: Box<dyn Freight>)
fn register_freight(&mut self, freight: Box<dyn Freight>)
Function that gets a
Freight
implementor passed as an
argument and is used to use it wherever it is needed in the
FreightRegistrar
implementorAuto Trait Implementations§
impl Freeze for FreightProxy
impl !RefUnwindSafe for FreightProxy
impl !Send for FreightProxy
impl !Sync for FreightProxy
impl Unpin for FreightProxy
impl !UnwindSafe for FreightProxy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more