cprocsp-sys 0.0.5

CryptoPRO bindings
Documentation
//
// Copyright © 2023, Oleg Lelenkov <o.lelenkov@gmail.com>
// License: Distributed under terms of the BSD 3-Clause license.
//

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

pub mod types {
    include!(concat!(env!("BINDGEN_OUT_PATH"), "/types_bindings.rs"));
}

pub mod ssp {
    use super::types::*;
    include!(concat!(env!("BINDGEN_OUT_PATH"), "/ssp_bindings.rs"));

    impl SSP {
        pub unsafe fn system() -> Result<Self, libloading::Error> {
            if cfg!(target_arch = "x86_64") {
                Self::new("/opt/cprocsp/lib/amd64/libssp.so")
            } else if cfg!(target_arch = "x86") {
                Self::new("/opt/cprocsp/lib/ia32/libssp.so")
            } else {
                Err(libloading::Error::IncompatibleSize)
            }
        }
    }
}

pub mod cades {
    use super::types::*;
    include!(concat!(env!("BINDGEN_OUT_PATH"), "/cades_bindings.rs"));

    impl Cades {
        pub unsafe fn system() -> Result<Self, libloading::Error> {
            if cfg!(target_arch = "x86_64") {
                Self::new("/opt/cprocsp/lib/amd64/libcades.so")
            } else if cfg!(target_arch = "x86") {
                Self::new("/opt/cprocsp/lib/ia32/libcades.so")
            } else {
                Err(libloading::Error::IncompatibleSize)
            }
        }
    }
}