bladerf_sys/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Bindgen generated bindings for libbladerf

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

use std::ffi::CStr;

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

impl bladerf_devinfo {
    /// Fetch serial string
    pub fn serial(&self) -> String {
        let mut s = [0u8; 33];
        for i in 0..self.serial.len() {
            s[i] = self.serial[i] as u8;
        }

        CStr::from_bytes_until_nul(&s)
            .map(|v| v.to_string_lossy().into_owned())
            .unwrap_or("".to_string())
    }
}

#[cfg(test)]
mod tests {
    // TODO: any useful binding tests?
}