pub struct Config {
pub output: PathBuf,
pub classes: Vec<ClassSpec>,
pub mapped: Vec<MappedSpec>,
}Fields§
§output: PathBuf§classes: Vec<ClassSpec>§mapped: Vec<MappedSpec>Implementations§
Source§impl Config
impl Config
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Examples found in repository?
examples/codegen_workflow.rs (line 32)
12fn main() -> codegen::Result<()> {
13 let root = std::env::temp_dir().join(format!(
14 "gemstone-rs-codegen-workflow-{}",
15 std::process::id()
16 ));
17 if root.exists() {
18 fs::remove_dir_all(&root)?;
19 }
20 fs::create_dir_all(&root)?;
21
22 let config_path = root.join("gemstone-rs.codegen");
23 fs::write(
24 &config_path,
25 "# gemstone-rs codegen workflow example\n\
26 output = generated/gemstone_wrappers.rs\n\
27 class = Object\n\
28 method = Object>>printString | return=String | doc=Return the receiver printString.\n\
29 method = Object>>class\n",
30 )?;
31
32 let config = Config::from_file(&config_path)?;
33 println!("config: {}", config_path.display());
34 println!("output: {}", config.output.display());
35
36 let preview = codegen::generate(&config);
37 println!("preview bytes: {}", preview.source.len());
38 println!(
39 "preview first line: {}",
40 preview.source.lines().next().unwrap_or_default()
41 );
42
43 let before = codegen::diff(&config)?;
44 println!(
45 "before generate: exists={} up_to_date={} diff_bytes={}",
46 before.exists,
47 before.up_to_date,
48 before.diff.len()
49 );
50 assert!(!before.up_to_date);
51
52 let generated = codegen::generate_to_file(&config)?;
53 println!("generated: {}", generated.output.display());
54
55 let check = codegen::check(&config)?;
56 println!(
57 "after generate: exists={} up_to_date={}",
58 check.exists, check.up_to_date
59 );
60 assert!(check.exists);
61 assert!(check.up_to_date);
62
63 let after = codegen::diff(&config)?;
64 assert!(after.diff.is_empty());
65 println!("diff after generate: clean");
66
67 Ok(())
68}Trait Implementations§
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more