(
endpoint_prefix: &str,
base_input_path: &Path,
input_path: PathBuf,
state: &mut BuildState,
input: &QsyncInput,
)
| 314 | |
| 315 | #[allow(clippy::too_many_lines)] |
| 316 | fn process_service_file( |
| 317 | endpoint_prefix: &str, |
| 318 | base_input_path: &Path, |
| 319 | input_path: PathBuf, |
| 320 | state: &mut BuildState, |
| 321 | input: &QsyncInput, |
| 322 | ) { |
| 323 | if state.is_debug { |
| 324 | println!( |
| 325 | "processing rust file: {:?}", |
| 326 | input_path.clone().into_os_string().into_string().unwrap() |
| 327 | ); |
| 328 | } |
| 329 | |
| 330 | let file = File::open(&input_path); |
| 331 | |
| 332 | if file.is_err() { |
| 333 | state.unprocessed_files.push(input_path); |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | let mut file = file.unwrap(); |
| 338 | |
| 339 | let mut src = String::new(); |
| 340 | if file.read_to_string(&mut src).is_err() { |
| 341 | state.unprocessed_files.push(input_path); |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | let syntax = syn::parse_file(&src); |
| 346 | |
| 347 | if syntax.is_err() { |
| 348 | state.unprocessed_files.push(input_path); |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | let syntax = syntax.unwrap(); |
| 353 | |
| 354 | for item in syntax.items { |
| 355 | if let syn::Item::Fn(exported_fn) = item { |
| 356 | let qsync_props = has_qsync_attribute(state.is_debug, &exported_fn.attrs); |
| 357 | |
| 358 | let has_qsync_attribute = qsync_props.is_some(); |
| 359 | |
| 360 | if state.is_debug { |
| 361 | if has_qsync_attribute { |
| 362 | println!( |
| 363 | "Encountered #[get|post|put|delete] struct: {}", |
| 364 | exported_fn.sig.ident |
| 365 | ); |
| 366 | } else { |
| 367 | println!("Encountered non-query struct: {}", exported_fn.sig.ident); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | if has_qsync_attribute { |
| 372 | let qsync_props = qsync_props.unwrap(); |
| 373 | let mut hook = Hook { |
no test coverage detected