/// Load a plugin at the given path with the given host.
///
/// Because of the possibility of multi-threading problems that can occur when using plugins,
/// the host must be passed in via an `Arc<Mutex<T>>` object. This makes sure that even if the
/// plugins are multi-threaded no data race issues can occur.
///
/// Upon success, this method returns a [`PluginLoader`](.) object which you can use to call
/// [`instance`](#method.instance) to create a new instance of the plugin.
///
/// # Example
///
/// ```no_run
/// # use std::path::Path;
/// # use std::sync::{Arc, Mutex};
/// # use vst2::host::{Host, PluginLoader};
/// # let path = Path::new(".");
/// # struct MyHost;
/// # impl MyHost { fn new() -> MyHost { MyHost } }
/// # impl Host for MyHost {
/// #     fn automate(&mut self, _: i32, _: f32) {}
/// #     fn get_plugin_id(&self) -> i32 { 0 }
/// # }
/// // ...
/// let host = Arc::new(Mutex::new(MyHost::new()));
///
/// let mut plugin = PluginLoader::load(path, host.clone()).unwrap();
///
/// let instance = plugin.instance().unwrap();
/// // ...
/// ```
///
/// # Linux/Windows
///   * This should be a path to the library, typically ending in `.so`/`.dll`.
///   * Possible full path: `/home/overdrivenpotato/.vst/u-he/Zebra2.64.so`
///   * Possible full path: `C:\Program Files (x86)\VSTPlugins\iZotope Ozone 5.dll`
///
/// # OS X
///   * This should point to the mach-o file within the `.vst` bundle.
///   * Plugin: `/Library/Audio/Plug-Ins/VST/iZotope Ozone 5.vst`
///   * Possible full path:
///     `/Library/Audio/Plug-Ins/VST/iZotope Ozone 5.vst/Contents/MacOS/PluginHooksVST`
Load a plugin at the given path with the given host.
Because of the possibility of multi-threading problems that can occur when using plugins,
the host must be passed in via an `Arc>` object. This makes sure that even if the
plugins are multi-threaded no data race issues can occur.

Upon success, this method returns a [`PluginLoader`](.) object which you can use to call
[`instance`](#method.instance) to create a new instance of the plugin.
Load a plugin at the given path with the given host . Because of the possibility of multi - threading problems that can occur when using plugins the host must be passed in via an ` Arc > ` object . This makes sure that even if the plugins are multi - threaded no data race issues can occur . Upon success this method returns a [ ` PluginLoader ` ] ( . ) object which you can use to call [ ` instance ` ] ( #method . instance ) to create a new instance of the plugin .
pub fn load(path: &Path, host: Arc<Mutex<T>>) -> Result<PluginLoader<T>, PluginLoadError> {
        // Try loading the library at the given path
        let lib = match Library::new(path) {
            Ok(l) => l,
            Err(_) => return Err(PluginLoadError::InvalidPath)
        };
        Ok(PluginLoader {
            main: unsafe {
                      // Search the library for the VSTAPI entry point
                      match lib.get(b"VSTPluginMain") {
                          Ok(s) => *s,
                          _ => return Err(PluginLoadError::NotAPlugin)
                      }
                  },
            lib: Arc::new(lib),
            host: host,
        })
    }
pub fn load ( path : & Path , host : Arc < Mutex < T > > ) -> Result < PluginLoader < T > , PluginLoadError > { // Try loading the library at the given path let lib = match Library :: new ( path ) { Ok ( l ) => l , Err ( _ ) => return Err ( PluginLoadError :: InvalidPath ) } ; Ok ( PluginLoader { main : unsafe { // Search the library for the VSTAPI entry point match lib . get ( b" " ) { Ok ( s ) => * s , _ => return Err ( PluginLoadError :: NotAPlugin ) } } , lib : Arc :: new ( lib ) , host : host , } ) }
Load a plugin at the given path with the given host.
Load a plugin at the given path with the given host .
path
&Path
host
Arc<Mutex<T>>
example
None
use std::path::path;
None
use std::sync::{arc, mutex};
None
use vst2::host::{host, pluginloader};
None
let path = path::new(".");
None
struct myhost;
None
impl myhost { fn new() -> myhost { myhost } }
None
impl host for myhost {
None
fn automate(&mut self, _: i32, _: f32) {}
None
fn get_plugin_id(&self) -> i32 { 0 }
None
}


let mut plugin = PluginLoader::load(path, host.clone()).unwrap().

let instance = plugin.instance().unwrap();

```
let mut plugin = PluginLoader :: load ( path host . clone () ) . unwrap () . let instance = plugin . instance () . unwrap () ; ` ` `
linux/windows
This should be a path to the library, typically ending in `.so`/`.dll`.
Possible full path: `/home/overdrivenpotato/.vst/u-he/Zebra2.64.so`
Possible full path: `C:\Program Files (x86)\VSTPlugins\iZotope Ozone 5.dll`
This should be a path to the library typically ending in ` . so ` / ` . dll ` . Possible full path : ` / home / overdrivenpotato / . vst / u - he / Zebra2 . 64 . so ` Possible full path : ` C : \ Program Files ( x86 ) \ VSTPlugins \ iZotope Ozone 5 . dll `
os x
This should point to the mach-o file within the `.vst` bundle.
Plugin: `/Library/Audio/Plug-Ins/VST/iZotope Ozone 5.vst`
Possible full path:
`/Library/Audio/Plug-Ins/VST/iZotope Ozone 5.vst/Contents/MacOS/PluginHooksVST`
This should point to the mach - o file within the ` . vst ` bundle . Plugin : ` / Library / Audio / Plug - Ins / VST / iZotope Ozone 5 . vst ` Possible full path : ` / Library / Audio / Plug - Ins / VST / iZotope Ozone 5 . vst / Contents / MacOS / PluginHooksVST `