Skip to main content

Library

Struct Library 

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

Dynamically-loaded NVIDIA library (wraps libloading::Library).

Implementations§

Source§

impl Library

Source

pub fn open( name: &'static str, candidates: &[&'static str], ) -> Result<Self, LoaderError>

Open candidates[0], candidates[1], … in order, falling back to each path returned by platform::library_search_paths. Returns the first success or LoaderError::LibraryNotFound / platform error.

Source

pub fn open_at(name: &'static str, path: &Path) -> Result<Self, LoaderError>

Open a library at the specific path path (no search). Mostly used in tests to inject a known library location.

Source

pub fn name(&self) -> &'static str

The logical library name baracuda knows it by (e.g. "cuda-driver", "cublas").

Source

pub fn resolved_from(&self) -> Option<&Path>

The absolute path the library actually resolved from, if known.

Source

pub unsafe fn symbol<T>( &self, symbol: &'static str, ) -> Result<Symbol<'_, T>, LoaderError>

Resolve symbol. The caller is responsible for the type T matching the C signature of the symbol; consequently, this function is unsafe.

§Errors

LoaderError::SymbolNotFound if dlsym/GetProcAddress returns a null pointer; LoaderError::Libloading for other libloading failures.

§Safety

T must be a function-pointer type (unsafe extern "C" fn(...) -> ...) matching the C signature of symbol. Calling the returned symbol with the wrong signature is undefined behavior.

Source

pub unsafe fn raw_symbol( &self, symbol: &'static str, ) -> Result<*mut (), LoaderError>

Return a raw pointer to the symbol without wrapping in libloading::Symbol. Useful for stashing function pointers in OnceLocks that outlive the borrow checker’s view of the library.

§Safety

Same as Self::symbol. Additionally, the caller must ensure the Library outlives any use of the returned pointer — in practice this means storing the Library in a static OnceLock<Library> or equivalent.

Trait Implementations§

Source§

impl Debug for Library

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.