mirror of https://github.com/aya-rs/aya
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			28 lines
		
	
	
		
			681 B
		
	
	
	
		
			Rust
		
	
			
		
		
	
	
			28 lines
		
	
	
		
			681 B
		
	
	
	
		
			Rust
		
	
| use std::{
 | |
|     fs::{create_dir_all, File},
 | |
|     io::{self, Write},
 | |
|     path::Path,
 | |
| };
 | |
| 
 | |
| pub mod bindgen;
 | |
| pub mod generate;
 | |
| pub mod rustfmt;
 | |
| 
 | |
| pub use generate::{generate, InputFile};
 | |
| 
 | |
| pub fn write_to_file<T: AsRef<Path>>(path: T, code: &str) -> Result<(), io::Error> {
 | |
|     // Create parent directories if they don't exist already
 | |
|     if let Some(parent) = path.as_ref().parent() {
 | |
|         if !parent.exists() {
 | |
|             create_dir_all(parent)?;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     let mut file = File::create(path)?;
 | |
|     file.write_all(code.as_bytes())
 | |
| }
 | |
| 
 | |
| pub fn write_to_file_fmt<T: AsRef<Path>>(path: T, code: &str) -> Result<(), io::Error> {
 | |
|     write_to_file(path, &rustfmt::format(code)?)
 | |
| }
 |