pub struct Config {
glob_sets: BTreeMap<String, Vec<String>>,
pub(crate) rules: BTreeMap<String, RuleConfig>,
workspace: WorkspaceContext,
}Expand description
Top-level tidy configuration loaded from tidy.toml.
Fields§
§glob_sets: BTreeMap<String, Vec<String>>§rules: BTreeMap<String, RuleConfig>§workspace: WorkspaceContextImplementations§
Source§impl Config
impl Config
Sourcepub fn load(path: &Path) -> Result<Config, ConfigError>
pub fn load(path: &Path) -> Result<Config, ConfigError>
Load, parse, and resolve a config file (expands glob set references).
§Errors
Returns an error when the file cannot be read, parsed, or resolved against its glob sets.
pub fn is_enabled(&self, name: &str) -> bool
pub fn ignore_patterns(&self, name: &str) -> &[String]
pub fn get_str_array(&self, rule: &str, param: &RuleParam) -> Vec<String>
Sourcepub fn validate(
&self,
registered: &[(&str, &'static [RuleParam])],
) -> (Vec<String>, Vec<String>)
pub fn validate( &self, registered: &[(&str, &'static [RuleParam])], ) -> (Vec<String>, Vec<String>)
Validate config against registered rules, returning (errors, warnings).
pub fn backfill_defaults(&mut self, registered: &[(&str, &'static [RuleParam])])
pub fn generate_default(registered: &[(&str, &'static [RuleParam])]) -> Config
Sourcepub fn to_toml_string(&self) -> String
pub fn to_toml_string(&self) -> String
Serializes this configuration with the standard explanatory header.
§Panics
Panics if the resolved configuration cannot be serialized as TOML.
Sourcepub fn resolved_rules(&self, rules: &[RuleMeta]) -> Vec<ConfigRule>
pub fn resolved_rules(&self, rules: &[RuleMeta]) -> Vec<ConfigRule>
Merge resolved configuration with registered rule metadata.
pub(crate) fn get_i64(&self, rule: &str, param: &RuleParam) -> i64
pub(crate) fn get_u64(&self, rule: &str, param: &RuleParam) -> u64
pub(crate) fn get_usize(&self, rule: &str, param: &RuleParam) -> usize
pub(crate) fn workspace(&self) -> &WorkspaceContext
fn resolve(raw: RawConfig) -> Result<Config, ConfigError>
fn validate_param( rule: &str, param: &RuleParam, cfg: &RuleConfig, errors: &mut Vec<String>, )
Trait Implementations§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more