Warning, /sdk/rust-qt-binding-generator/src/lib.rs is written in an unsupported language. File is not indexed.

0001 extern crate regex;
0002 #[macro_use]
0003 extern crate serde_derive;
0004 extern crate serde_json;
0005 extern crate serde_xml_rs;
0006 extern crate toml;
0007 
0008 pub mod build;
0009 pub mod configuration;
0010 mod configuration_private;
0011 mod cpp;
0012 mod rust;
0013 mod util;
0014 
0015 use configuration::Config;
0016 use std::error::Error;
0017 use std::path::Path;
0018 
0019 /// Read a file with bindings.
0020 pub fn read_bindings_file<P: AsRef<Path>>(config_file: P) -> Result<Config, Box<dyn Error>> {
0021     configuration::parse(config_file)
0022 }
0023 
0024 /// Generate bindings from a bindings configuration.
0025 pub fn generate_bindings(config: &Config) -> Result<(), Box<dyn Error>> {
0026     cpp::write_header(config)?;
0027     cpp::write_cpp(config)?;
0028     rust::write_interface(config)?;
0029     rust::write_implementation(config)?;
0030     Ok(())
0031 }
0032 
0033 /// Generate bindings from a bindings configuration file.
0034 pub fn generate_bindings_from_config_file<P: AsRef<Path>>(
0035     config_file: P,
0036     overwrite_implementation: bool,
0037 ) -> Result<(), Box<dyn Error>> {
0038     let mut config = read_bindings_file(config_file)?;
0039     if overwrite_implementation {
0040         config.overwrite_implementation = true;
0041     }
0042     generate_bindings(&config)
0043 }