Skip to main content

load_library

Function load_library 

Source
pub unsafe fn load_library(path: &str) -> Result<(), Box<dyn Error>>
Expand description

Load the libcronet shared library at runtime.

path may be either:

  • a file — loaded directly (e.g. "libcronet.so", "C:\\libs\\libcronet.dll");
  • a directory — scanned recursively for the loadable library that best matches the current platform and architecture (see find_platform_library). This is handy for pointing at a download/output tree without knowing the exact asset file name or its sub-path (load_library("dylibs") will find dylibs/windows-amd64/libcronet.dll).

Must be called before any other FFI function (engine creation, etc.). On success, the library stays loaded for the lifetime of the process.

§Safety

Use a trusted SagerNet Cronet library. A failed load can be retried. After a successful load the library stays active for the process lifetime.