sharedlib 6.0.0

A cross-platform shared library loader.
Documentation
use FuncUnsafe;
use Symbol;

/// A pointer to a shared function which allows a user-provided ref-counting implementation to avoid outliving its library.
#[derive(Debug)]
pub struct FuncTracked<T, TLib> {
    func: FuncUnsafe<T>,
    _lib: TLib,
}

impl <T, TLib> FuncTracked<T, TLib> {
    /// Creates a new [FuncTracked](struct.FuncTracked.html).
    /// This should only be called within the library.
    pub fn new(func: FuncUnsafe<T>, lib: TLib) -> Self {
        FuncTracked {
            func: func,
            _lib: lib,
        }
    }
}

impl <T, TLib> Symbol<T> for FuncTracked<T, TLib>
    where T: Copy {
    unsafe fn get(&self) -> T {
        self.func
    }
}

impl <T, TLib> Clone for FuncTracked<T, TLib>
    where T: Copy,
          TLib: Clone {
    fn clone(&self) -> Self {
        FuncTracked {
            func: self.func,
            _lib: self._lib.clone(),
        }
    }
}