• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
2 pub struct TestLib {
3     __library: ::libloading::Library,
4     pub foo: Result<
5         unsafe extern "C" fn(x: ::std::os::raw::c_int) -> ::std::os::raw::c_int,
6         ::libloading::Error,
7     >,
8     pub foo1: Result<unsafe extern "C" fn(x: f32) -> f32, ::libloading::Error>,
9 }
10 impl TestLib {
new<P>(path: P) -> Result<Self, ::libloading::Error> where P: AsRef<::std::ffi::OsStr>,11     pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
12     where
13         P: AsRef<::std::ffi::OsStr>,
14     {
15         let library = ::libloading::Library::new(path)?;
16         Self::from_library(library)
17     }
from_library<L>(library: L) -> Result<Self, ::libloading::Error> where L: Into<::libloading::Library>,18     pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
19     where
20         L: Into<::libloading::Library>,
21     {
22         let __library = library.into();
23         let foo = __library.get(b"foo\0").map(|sym| *sym);
24         let foo1 = __library.get(b"foo1\0").map(|sym| *sym);
25         Ok(TestLib { __library, foo, foo1 })
26     }
foo(&self, x: ::std::os::raw::c_int) -> ::std::os::raw::c_int27     pub unsafe fn foo(&self, x: ::std::os::raw::c_int) -> ::std::os::raw::c_int {
28         (self.foo.as_ref().expect("Expected function, got error."))(x)
29     }
foo1(&self, x: f32) -> f3230     pub unsafe fn foo1(&self, x: f32) -> f32 {
31         (self.foo1.as_ref().expect("Expected function, got error."))(x)
32     }
33 }
34