dissolve_python/checker.rs
1// Copyright (C) 2024 Jelmer Vernooij <jelmer@samba.org>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Verification functionality for @replace_me decorated functions.
16//!
17//! This module provides the CheckResult type used by the check functionality.
18
19/// Result of checking @replace_me decorated functions
20#[derive(Debug, Clone)]
21pub struct CheckResult {
22 /// True if all replacements are valid, False otherwise
23 pub success: bool,
24 /// List of error messages for invalid replacements
25 pub errors: Vec<String>,
26 /// List of function names that were checked
27 pub checked_functions: Vec<String>,
28}
29
30impl CheckResult {
31 pub fn new() -> Self {
32 Self {
33 success: true,
34 errors: Vec::new(),
35 checked_functions: Vec::new(),
36 }
37 }
38
39 pub fn add_error(&mut self, error: String) {
40 self.success = false;
41 self.errors.push(error);
42 }
43
44 pub fn add_checked_function(&mut self, name: String) {
45 self.checked_functions.push(name);
46 }
47}
48
49impl Default for CheckResult {
50 fn default() -> Self {
51 Self::new()
52 }
53}