libftd3xx/lib.rs
1use libftd3xx_ffi::prelude::*;
2
3type Result<T> = std::result::Result<T, FT_STATUS>;
4
5/// Returns the version of the underlying C library.
6///
7/// **Note**: The documentation says this function is only supported on Windows
8/// but it seems to work correctly on Linux.
9///
10/// # Example
11///
12/// ```no_run
13/// use libftd2xx::library_version;
14///
15/// let version = library_version()?;
16/// println!("libftd2xx C library version: {}", version);
17/// # Ok::<(), libftd2xx::FtStatus>(())
18/// ```
19pub fn library_version() -> Result<u32> {
20 let mut version: u32 = 0;
21 //trace!("FT_GetLibraryVersion(_)");
22 let status: FT_STATUS = unsafe { FT_GetLibraryVersion(&mut version) };
23 if status == FT_OK as FT_STATUS {
24 return Ok(version);
25 } else {
26 return Err(status);
27 }
28}