Struct FreightProxy

Source
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

Source

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

Source§

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>

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>)

Function that updates system limitations
Source§

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)

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>

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>

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>

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

Source§

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 implementor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.