pub struct LibraryHandle(/* private fields */);Available on macOS only.
Expand description
A RAII wrapper around a dlopen handle.
Opens a dynamic library on construction and closes it on drop. After an
explicit close, the destructor is disarmed.
Implementations§
Source§impl LibraryHandle
impl LibraryHandle
Sourcepub unsafe fn symbol(&self, name: &CStr) -> Result<LibrarySymbol, LoadError>
pub unsafe fn symbol(&self, name: &CStr) -> Result<LibrarySymbol, LoadError>
Resolves a named symbol from the loaded library.
The returned LibrarySymbol is typically transmuted into a typed function pointer
via core::mem::transmute.
§Safety
The caller must ensure that:
nameidentifies a symbol whose actual signature matches the type it will be transmuted to.- The resulting
LibrarySymbol(or any pointer derived from it) is not used after this handle is closed or dropped.
§Errors
Returns LoadError if the symbol cannot be found in the library.
Sourcepub unsafe fn close(self) -> Result<(), LoadError>
pub unsafe fn close(self) -> Result<(), LoadError>
Explicitly closes the library handle and returns any error from dlclose.
After this call the destructor is disarmed; dropping the handle is a no-op.
§Errors
Returns LoadError if dlclose fails.
§Safety
The caller must ensure that no LibrarySymbol (or function pointer derived from
one) obtained from this handle is used after this call returns.
Trait Implementations§
Source§impl Debug for LibraryHandle
impl Debug for LibraryHandle
Source§impl Drop for LibraryHandle
impl Drop for LibraryHandle
impl Send for LibraryHandle
impl Sync for LibraryHandle
Auto Trait Implementations§
impl Freeze for LibraryHandle
impl RefUnwindSafe for LibraryHandle
impl Unpin for LibraryHandle
impl UnsafeUnpin for LibraryHandle
impl UnwindSafe for LibraryHandle
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