pub struct Library { /* private fields */ }Expand description
Dynamically-loaded NVIDIA library (wraps libloading::Library).
Implementations§
Source§impl Library
impl Library
Sourcepub fn open(
name: &'static str,
candidates: &[&'static str],
) -> Result<Self, LoaderError>
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.
Sourcepub fn open_at(name: &'static str, path: &Path) -> Result<Self, LoaderError>
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.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
The logical library name baracuda knows it by (e.g. "cuda-driver",
"cublas").
Sourcepub fn resolved_from(&self) -> Option<&Path>
pub fn resolved_from(&self) -> Option<&Path>
The absolute path the library actually resolved from, if known.
Sourcepub unsafe fn symbol<T>(
&self,
symbol: &'static str,
) -> Result<Symbol<'_, T>, LoaderError>
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.
Sourcepub unsafe fn raw_symbol(
&self,
symbol: &'static str,
) -> Result<*mut (), LoaderError>
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.