Struct Library

Source
pub struct Library { /* private fields */ }
Expand description

A handle wrapper with a VTable of symbols found in the library as they’re requested.

Implementations§

Source§

impl Library

Source

pub unsafe fn handle(&self) -> &*mut c_void

Returns an unsafe reference to the handle of the library. Usually, the [sym] and drop methods are enough, but you’re free to use it for anything else, provided you can dereference it.

Source

pub unsafe fn table(&self) -> &HashMap<String, *mut c_void>

Returns an unsafe reference to the VTable of the library. Usually, the [sym] method is enough, though you’re free to use it for what you may want to use it for.

Source

pub fn name(&self) -> String

Returns the path of the dynamic library as given to [open] or [new].

Source

pub fn sym<T>(&mut self, name: String) -> Option<Box<T>>

Requests and finds a symbol in the library. So long [RtldOr::Local] wasn’t specified, it will also look at other loaded symbols which are either in the program itself or were loaded with [RtldOr::Global].

Source

pub fn open(name: String, flags: RtldValue, closure: fn(lib: Library)) -> bool

Makes a safe instance using [new] then applies the closure given to it. It returns true if it was successful, or false if anything went wrong.

Source

pub unsafe fn new(name_c: CString, flags: RtldValue) -> Option<Self>

Creates a new instance of the library wanted. There are no checks other than handle checks upon loading it. It is the user’s responsibility to pass a valid CString instance and valid flags.

Trait Implementations§

Source§

impl Drop for Library

Source§

fn drop(&mut self)

Closes the handle then drops the entire library.

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.