diff --git a/src/archive/find.rs b/src/archive/find.rs index 58a54127..38bc08ff 100644 --- a/src/archive/find.rs +++ b/src/archive/find.rs @@ -10,7 +10,7 @@ use crate::{GameType, game::GameCache, plugin::has_ascii_extension}; const BSA_FILE_EXTENSION: &str = "bsa"; -pub fn find_associated_archives( +pub(crate) fn find_associated_archives( game_type: GameType, game_cache: &GameCache, plugin_path: &Path, @@ -205,7 +205,7 @@ mod tests { } impl Fixture { - pub fn new(game_type: GameType) -> Self { + fn new(game_type: GameType) -> Self { let tmp_dir = tempdir().unwrap(); let mut cache = GameCache::default(); diff --git a/src/archive/mod.rs b/src/archive/mod.rs index 936a3ae9..b8badc71 100644 --- a/src/archive/mod.rs +++ b/src/archive/mod.rs @@ -6,10 +6,10 @@ mod parse; use std::collections::{BTreeMap, BTreeSet}; -pub use find::find_associated_archives; -pub use parse::assets_in_archives; +pub(crate) use find::find_associated_archives; +pub(crate) use parse::assets_in_archives; -pub fn do_assets_overlap( +pub(crate) fn do_assets_overlap( assets: &BTreeMap>, other_assets: &BTreeMap>, ) -> bool { diff --git a/src/archive/parse.rs b/src/archive/parse.rs index 2497198c..e8f9e079 100644 --- a/src/archive/parse.rs +++ b/src/archive/parse.rs @@ -14,7 +14,7 @@ use crate::{ use super::{ba2, bsa}; -pub fn assets_in_archives(archive_paths: &[PathBuf]) -> BTreeMap> { +pub(crate) fn assets_in_archives(archive_paths: &[PathBuf]) -> BTreeMap> { let mut archive_assets: BTreeMap> = BTreeMap::new(); for archive_path in archive_paths { diff --git a/src/database/conditions.rs b/src/database/conditions.rs index 0c86d7df..7598f62b 100644 --- a/src/database/conditions.rs +++ b/src/database/conditions.rs @@ -4,7 +4,7 @@ use loot_condition_interpreter::Expression; use crate::metadata::{File, PluginCleaningData, PluginMetadata}; -pub fn evaluate_all_conditions( +pub(crate) fn evaluate_all_conditions( mut metadata: PluginMetadata, state: &loot_condition_interpreter::State, ) -> Result, loot_condition_interpreter::Error> { @@ -57,7 +57,7 @@ pub fn evaluate_all_conditions( } } -pub fn evaluate_condition( +pub(crate) fn evaluate_condition( condition: &str, state: &loot_condition_interpreter::State, ) -> Result { @@ -75,7 +75,7 @@ fn evaluate_condition_option( } } -pub fn filter_map_on_condition( +pub(crate) fn filter_map_on_condition( item: &T, condition: Option<&str>, state: &loot_condition_interpreter::State, diff --git a/src/game.rs b/src/game.rs index c278546a..ab1097da 100644 --- a/src/game.rs +++ b/src/game.rs @@ -773,7 +773,7 @@ pub(crate) struct GameCache { } impl GameCache { - pub fn set_archive_paths(&mut self, archive_paths: Vec) { + pub(crate) fn set_archive_paths(&mut self, archive_paths: Vec) { self.archive_paths.clear(); self.archive_paths.extend(archive_paths); } @@ -801,7 +801,7 @@ impl GameCache { self.plugins.get(&Filename::new(plugin_name.to_owned())) } - pub fn archives_iter(&self) -> impl Iterator { + pub(crate) fn archives_iter(&self) -> impl Iterator { self.archive_paths.iter() } } diff --git a/src/lib.rs b/src/lib.rs index dff36bd3..2f198912 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ // Allow some lints that are denied at the workspace level. #![allow( - unreachable_pub, clippy::doc_markdown, clippy::exhaustive_enums, clippy::filetype_is_file, diff --git a/src/logging.rs b/src/logging.rs index b27a9a62..4ee17885 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -147,7 +147,7 @@ macro_rules! trace { ($($arg:tt)+) => { $crate::logging::log!(crate::LogLevel::Trace, $($arg)+) }; } -pub fn is_log_enabled(level: LogLevel) -> bool { +pub(crate) fn is_log_enabled(level: LogLevel) -> bool { if log::log_enabled!(level.into()) { return true; } diff --git a/src/metadata/metadata_document.rs b/src/metadata/metadata_document.rs index 70fe0b63..698d29d2 100644 --- a/src/metadata/metadata_document.rs +++ b/src/metadata/metadata_document.rs @@ -22,7 +22,7 @@ use super::{ }; #[derive(Clone, Debug, Eq, PartialEq)] -pub struct MetadataDocument { +pub(crate) struct MetadataDocument { bash_tags: Vec, groups: Vec, messages: Vec, @@ -31,7 +31,7 @@ pub struct MetadataDocument { } impl MetadataDocument { - pub fn load(&mut self, file_path: &Path) -> Result<(), LoadMetadataError> { + pub(crate) fn load(&mut self, file_path: &Path) -> Result<(), LoadMetadataError> { if !file_path.exists() { return Err(LoadMetadataError::new( file_path.into(), @@ -55,7 +55,7 @@ impl MetadataDocument { Ok(()) } - pub fn load_with_prelude( + pub(crate) fn load_with_prelude( &mut self, masterlist_path: &Path, prelude_path: &Path, @@ -199,7 +199,7 @@ impl MetadataDocument { Ok(()) } - pub fn save(&self, file_path: &Path) -> Result<(), WriteMetadataError> { + pub(crate) fn save(&self, file_path: &Path) -> Result<(), WriteMetadataError> { logging::trace!("Saving metadata list to: \"{}\"", escape_ascii(file_path)); let mut emitter = YamlEmitter::new(); @@ -251,23 +251,26 @@ impl MetadataDocument { Ok(()) } - pub fn bash_tags(&self) -> &[String] { + pub(crate) fn bash_tags(&self) -> &[String] { &self.bash_tags } - pub fn groups(&self) -> &[Group] { + pub(crate) fn groups(&self) -> &[Group] { &self.groups } - pub fn messages(&self) -> &[Message] { + pub(crate) fn messages(&self) -> &[Message] { &self.messages } - pub fn plugins_iter(&self) -> impl Iterator { + pub(crate) fn plugins_iter(&self) -> impl Iterator { self.plugins.values().chain(self.regex_plugins.iter()) } - pub fn find_plugin(&self, plugin_name: &str) -> Result, RegexError> { + pub(crate) fn find_plugin( + &self, + plugin_name: &str, + ) -> Result, RegexError> { let mut metadata = match self.plugins.get(&Filename::new(plugin_name.to_owned())) { Some(m) => m.clone(), None => PluginMetadata::new(plugin_name)?, @@ -287,7 +290,7 @@ impl MetadataDocument { } } - pub fn set_groups(&mut self, groups: Vec) { + pub(crate) fn set_groups(&mut self, groups: Vec) { // Ensure that the default group is present. let default_group_exists = groups.iter().any(|g| g.name() == Group::DEFAULT_NAME); @@ -300,7 +303,7 @@ impl MetadataDocument { } } - pub fn set_plugin_metadata(&mut self, plugin_metadata: PluginMetadata) { + pub(crate) fn set_plugin_metadata(&mut self, plugin_metadata: PluginMetadata) { if plugin_metadata.is_regex_plugin() { self.regex_plugins.push(plugin_metadata); } else { @@ -311,11 +314,11 @@ impl MetadataDocument { } } - pub fn remove_plugin_metadata(&mut self, plugin_name: &str) { + pub(crate) fn remove_plugin_metadata(&mut self, plugin_name: &str) { self.plugins.remove(&Filename::new(plugin_name.to_owned())); } - pub fn clear(&mut self) { + pub(crate) fn clear(&mut self) { self.bash_tags.clear(); self.groups.clear(); self.messages.clear(); diff --git a/src/metadata/yaml/emit.rs b/src/metadata/yaml/emit.rs index a4a554bc..ffef4961 100644 --- a/src/metadata/yaml/emit.rs +++ b/src/metadata/yaml/emit.rs @@ -1,4 +1,4 @@ -pub trait EmitYaml { +pub(in crate::metadata) trait EmitYaml { fn is_scalar(&self) -> bool { false } @@ -7,7 +7,7 @@ pub trait EmitYaml { } #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct YamlEmitter { +pub(in crate::metadata) struct YamlEmitter { buffer: String, scope: Vec, style: YamlStyle, @@ -34,7 +34,7 @@ impl YamlEmitter { const INDENT_UNIT: &str = " "; const ARRAY_ELEMENT_PREFIX: &str = "- "; - pub fn new() -> Self { + pub(in crate::metadata) fn new() -> Self { Self { buffer: String::new(), scope: vec![], @@ -42,11 +42,11 @@ impl YamlEmitter { } } - pub fn into_string(self) -> String { + pub(in crate::metadata) fn into_string(self) -> String { self.buffer } - pub fn unquoted_str(&mut self, value: &str) { + pub(in crate::metadata) fn unquoted_str(&mut self, value: &str) { if self.style == YamlStyle::Block { self.write_prefix(); } @@ -60,7 +60,7 @@ impl YamlEmitter { } } - pub fn single_quoted_str(&mut self, value: &str) { + pub(in crate::metadata) fn single_quoted_str(&mut self, value: &str) { if self.style == YamlStyle::Block { self.write_prefix(); } @@ -72,7 +72,7 @@ impl YamlEmitter { } } - pub fn u32(&mut self, value: u32) { + pub(in crate::metadata) fn u32(&mut self, value: u32) { if self.style == YamlStyle::Block { self.write_prefix(); } @@ -80,7 +80,7 @@ impl YamlEmitter { self.write(&value.to_string()); } - pub fn begin_map(&mut self) { + pub(in crate::metadata) fn begin_map(&mut self) { if self.scope.last() == Some(&YamlBlock::Array) { self.end_line(); self.write_indent(); @@ -88,7 +88,7 @@ impl YamlEmitter { } } - pub fn end_map(&mut self) { + pub(in crate::metadata) fn end_map(&mut self) { if self.scope.last() == Some(&YamlBlock::Map) { self.scope.pop(); } @@ -97,7 +97,7 @@ impl YamlEmitter { /// This assumes that the given key is valid to be written as an unquoted /// string, and expects a string literal so that it's obvious that a given /// value is valid. - pub fn map_key(&mut self, key: &'static str) { + pub(in crate::metadata) fn map_key(&mut self, key: &'static str) { match self.scope.last() { Some(&YamlBlock::Map) => { self.end_line(); @@ -109,7 +109,7 @@ impl YamlEmitter { self.write(&format!("{key}:")); } - pub fn begin_array(&mut self) { + pub(in crate::metadata) fn begin_array(&mut self) { if self.style == YamlStyle::Flow { if self.scope.last() == Some(&YamlBlock::Map) { self.write(" "); @@ -120,7 +120,7 @@ impl YamlEmitter { self.scope.push(YamlBlock::Array); } - pub fn end_array(&mut self) { + pub(in crate::metadata) fn end_array(&mut self) { if self.scope.last() == Some(&YamlBlock::Array) { self.scope.pop(); } @@ -130,11 +130,11 @@ impl YamlEmitter { } } - pub fn set_flow_style(&mut self) { + pub(in crate::metadata) fn set_flow_style(&mut self) { self.style = YamlStyle::Flow; } - pub fn set_block_style(&mut self) { + pub(in crate::metadata) fn set_block_style(&mut self) { self.style = YamlStyle::Block; } diff --git a/src/metadata/yaml/merge.rs b/src/metadata/yaml/merge.rs index 1ca5c986..2282ff91 100644 --- a/src/metadata/yaml/merge.rs +++ b/src/metadata/yaml/merge.rs @@ -2,7 +2,9 @@ use saphyr::{MarkedYaml, YamlData}; use crate::metadata::error::YamlMergeKeyError; -pub fn process_merge_keys(mut yaml: MarkedYaml) -> Result { +pub(in crate::metadata) fn process_merge_keys( + mut yaml: MarkedYaml, +) -> Result { match yaml.data { YamlData::Sequence(a) => { yaml.data = merge_array_elements(a).map(YamlData::Sequence)?; diff --git a/src/metadata/yaml/mod.rs b/src/metadata/yaml/mod.rs index 615b38b9..a47e1103 100644 --- a/src/metadata/yaml/mod.rs +++ b/src/metadata/yaml/mod.rs @@ -2,9 +2,9 @@ mod emit; mod merge; mod parse; -pub use emit::{EmitYaml, YamlEmitter}; -pub use merge::process_merge_keys; -pub use parse::{ +pub(in crate::metadata) use emit::{EmitYaml, YamlEmitter}; +pub(in crate::metadata) use merge::process_merge_keys; +pub(in crate::metadata) use parse::{ TryFromYaml, YamlObjectType, as_mapping, get_required_string_value, get_slice_value, get_string_value, get_strings_vec_value, get_u32_value, get_value, parse_condition, to_unmarked_yaml, diff --git a/src/metadata/yaml/parse.rs b/src/metadata/yaml/parse.rs index f12d827f..83538a3f 100644 --- a/src/metadata/yaml/parse.rs +++ b/src/metadata/yaml/parse.rs @@ -6,7 +6,7 @@ use saphyr::{AnnotatedMapping, MarkedYaml, Marker, Scalar, Yaml, YamlData}; use super::super::error::{ExpectedType, MetadataParsingErrorReason, ParseMetadataError}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub enum YamlObjectType { +pub(in crate::metadata) enum YamlObjectType { File, Group, Location, @@ -36,7 +36,7 @@ impl std::fmt::Display for YamlObjectType { } } -pub fn to_unmarked_yaml<'a>(yaml: &MarkedYaml<'a>) -> Yaml<'a> { +pub(in crate::metadata) fn to_unmarked_yaml<'a>(yaml: &MarkedYaml<'a>) -> Yaml<'a> { match &yaml.data { YamlData::Value(Scalar::FloatingPoint(v)) => Yaml::Value(Scalar::FloatingPoint(*v)), YamlData::Value(Scalar::Integer(v)) => Yaml::Value(Scalar::Integer(*v)), @@ -56,14 +56,14 @@ pub fn to_unmarked_yaml<'a>(yaml: &MarkedYaml<'a>) -> Yaml<'a> { } } -pub fn get_value<'a, 'b>( +pub(in crate::metadata) fn get_value<'a, 'b>( mapping: &'a AnnotatedMapping<'b, MarkedYaml<'b>>, key: &'static str, ) -> Option<&'a MarkedYaml<'b>> { mapping.get(&MarkedYaml::value_from_str(key)) } -pub fn get_string_value<'a>( +pub(in crate::metadata) fn get_string_value<'a>( mapping: &'a AnnotatedMapping, key: &'static str, yaml_type: YamlObjectType, @@ -82,7 +82,7 @@ pub fn get_string_value<'a>( } } -pub fn get_required_string_value<'a>( +pub(in crate::metadata) fn get_required_string_value<'a>( marker: Marker, mapping: &'a AnnotatedMapping, key: &'static str, @@ -94,7 +94,7 @@ pub fn get_required_string_value<'a>( } } -pub fn get_strings_vec_value<'a>( +pub(in crate::metadata) fn get_strings_vec_value<'a>( mapping: &'a AnnotatedMapping, key: &'static str, yaml_type: YamlObjectType, @@ -124,7 +124,7 @@ pub fn get_strings_vec_value<'a>( } } -pub fn as_mapping<'a, 'b>( +pub(in crate::metadata) fn as_mapping<'a, 'b>( value: &'a MarkedYaml<'b>, yaml_type: YamlObjectType, ) -> Result<&'a AnnotatedMapping<'a, MarkedYaml<'b>>, ParseMetadataError> { @@ -138,7 +138,7 @@ pub fn as_mapping<'a, 'b>( } } -pub fn get_u32_value( +pub(in crate::metadata) fn get_u32_value( mapping: &AnnotatedMapping, key: &'static str, yaml_type: YamlObjectType, @@ -159,7 +159,7 @@ pub fn get_u32_value( } } -pub fn get_slice_value<'a>( +pub(in crate::metadata) fn get_slice_value<'a>( mapping: &'a saphyr::AnnotatedMapping, key: &'static str, yaml_type: YamlObjectType, @@ -179,7 +179,7 @@ pub fn get_slice_value<'a>( } } -pub fn parse_condition( +pub(in crate::metadata) fn parse_condition( mapping: &saphyr::AnnotatedMapping, key: &'static str, yaml_type: YamlObjectType, @@ -198,6 +198,6 @@ pub fn parse_condition( /// This is effectively TryFrom<&MarkedYaml>, but implementing it doesn't make /// MarkedYaml part of the crate's public API. -pub trait TryFromYaml: Sized { +pub(in crate::metadata) trait TryFromYaml: Sized { fn try_from_yaml(value: &MarkedYaml) -> Result; } diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index 8d009cdc..84ac2576 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -1,4 +1,4 @@ -pub mod error; +pub(crate) mod error; use std::{ collections::{BTreeMap, BTreeSet}, diff --git a/src/sorting/error.rs b/src/sorting/error.rs index 4161eca8..88beee5f 100644 --- a/src/sorting/error.rs +++ b/src/sorting/error.rs @@ -26,7 +26,7 @@ impl Display for UndefinedGroupError { impl std::error::Error for UndefinedGroupError {} #[derive(Clone, Default, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] -pub struct CyclicInteractionError { +pub(crate) struct CyclicInteractionError { cycle: Vec, } diff --git a/src/sorting/groups.rs b/src/sorting/groups.rs index 35dc6d6f..6c5d026c 100644 --- a/src/sorting/groups.rs +++ b/src/sorting/groups.rs @@ -21,9 +21,9 @@ use super::{ search::{DfsVisitor, depth_first_search}, }; -pub type GroupsGraph = Graph, EdgeType>; +pub(super) type GroupsGraph = Graph, EdgeType>; -pub fn build_groups_graph( +pub(crate) fn build_groups_graph( masterlist_groups: &[Group], userlist_groups: &[Group], ) -> Result { @@ -115,7 +115,7 @@ fn sorted_clone(strings: &[String]) -> Vec<&str> { strings } -pub fn find_path( +pub(crate) fn find_path( graph: &GroupsGraph, from_group_name: &str, to_group_name: &str, @@ -211,7 +211,7 @@ fn find_node_by_weight( /// Sort the group vertices so that root vertices come first, in order of /// decreasing path length, but otherwise preserving the existing /// (lexicographical) ordering. -pub fn sorted_group_nodes(graph: &GroupsGraph) -> Vec { +pub(super) fn sorted_group_nodes(graph: &GroupsGraph) -> Vec { let mut nodes: Vec<(NodeIndex, bool, usize)> = graph .node_indices() .map(|n| { @@ -274,7 +274,9 @@ impl<'a> DfsVisitor<'a> for GroupsPathLengthVisitor { } } -pub fn get_default_group_node(graph: &GroupsGraph) -> Result { +pub(super) fn get_default_group_node( + graph: &GroupsGraph, +) -> Result { graph .node_indices() .find(|n| graph[*n].as_ref() == Group::DEFAULT_NAME) diff --git a/src/sorting/mod.rs b/src/sorting/mod.rs index ab003fb5..237485da 100644 --- a/src/sorting/mod.rs +++ b/src/sorting/mod.rs @@ -1,9 +1,9 @@ -pub mod error; -pub mod groups; -pub mod plugins; +pub(crate) mod error; +pub(crate) mod groups; +pub(crate) mod plugins; mod search; mod validate; -pub mod vertex; +pub(crate) mod vertex; #[cfg(test)] mod test { @@ -11,7 +11,7 @@ mod test { use crate::error::PluginDataError; #[derive(Default)] - pub struct TestPlugin { + pub(super) struct TestPlugin { name: String, masters: Vec, pub(super) is_master: bool, @@ -23,22 +23,22 @@ mod test { } impl TestPlugin { - pub fn new(name: &str) -> Self { + pub(super) fn new(name: &str) -> Self { Self { name: name.to_owned(), ..Default::default() } } - pub fn add_master(&mut self, plugin_name: &str) { + pub(super) fn add_master(&mut self, plugin_name: &str) { self.masters.push(plugin_name.to_owned()); } - pub fn add_overlapping_records(&mut self, plugin_name: &str) { + pub(super) fn add_overlapping_records(&mut self, plugin_name: &str) { self.overlapping_record_plugins.push(plugin_name.to_owned()); } - pub fn add_overlapping_assets(&mut self, plugin_name: &str) { + pub(super) fn add_overlapping_assets(&mut self, plugin_name: &str) { self.overlapping_asset_plugins.push(plugin_name.to_owned()); } } diff --git a/src/sorting/plugins.rs b/src/sorting/plugins.rs index ed36a0bb..002ab18a 100644 --- a/src/sorting/plugins.rs +++ b/src/sorting/plugins.rs @@ -25,7 +25,7 @@ use super::{ }; #[derive(Debug)] -pub struct PluginSortingData<'a, T: SortingPlugin> { +pub(crate) struct PluginSortingData<'a, T: SortingPlugin> { plugin: &'a T, pub(super) is_master: bool, override_record_count: usize, @@ -41,7 +41,7 @@ pub struct PluginSortingData<'a, T: SortingPlugin> { } impl<'a, T: SortingPlugin> PluginSortingData<'a, T> { - pub fn new( + pub(crate) fn new( plugin: &'a T, masterlist_metadata: Option<&PluginMetadata>, user_metadata: Option<&PluginMetadata>, @@ -100,7 +100,7 @@ impl<'a, T: SortingPlugin> PluginSortingData<'a, T> { } } -pub trait SortingPlugin { +pub(crate) trait SortingPlugin { fn name(&self) -> &str; fn is_master(&self) -> bool; fn is_blueprint_plugin(&self) -> bool; @@ -779,7 +779,7 @@ impl<'a, T: SortingPlugin> std::ops::Index for PluginsGraph<'a, T> { } } -pub fn sort_plugins( +pub(crate) fn sort_plugins( mut plugins_sorting_data: Vec>, groups_graph: &GroupsGraph, early_loading_plugins: &[String], diff --git a/src/sorting/search.rs b/src/sorting/search.rs index 42999941..c7cc9aff 100644 --- a/src/sorting/search.rs +++ b/src/sorting/search.rs @@ -9,7 +9,7 @@ use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use crate::{EdgeType, Vertex, logging}; -pub trait DfsVisitor<'a> { +pub(super) trait DfsVisitor<'a> { fn visit_tree_edge(&mut self, edge_ref: EdgeReference<'a, EdgeType>); fn visit_forward_or_cross_edge(&mut self, edge_ref: EdgeReference<'a, EdgeType>); @@ -21,7 +21,7 @@ pub trait DfsVisitor<'a> { fn finish_node(&mut self, node_index: NodeIndex); } -pub trait BidirBfsVisitor { +pub(super) trait BidirBfsVisitor { fn visit_forward_bfs_edge(&mut self, source: NodeIndex, target: NodeIndex); fn visit_reverse_bfs_edge(&mut self, source: NodeIndex, target: NodeIndex); @@ -29,7 +29,7 @@ pub trait BidirBfsVisitor { fn visit_intersection_node(&mut self, node: NodeIndex); } -pub fn bidirectional_bfs( +pub(super) fn bidirectional_bfs( graph: &Graph, from_index: NodeIndex, to_index: NodeIndex, @@ -78,7 +78,7 @@ pub fn bidirectional_bfs( } // Petgraph has APIs for performing depth-first searches, but they don't give any information about the current edge, only its source and target nodes, which is a problem if the same pair of nodes can have multiple edges between them with different weights. As such, implement it myself. -pub fn find_cycle( +pub(super) fn find_cycle( graph: &Graph, node_mapper: impl FnMut(&N) -> String, ) -> Option> { @@ -99,14 +99,14 @@ pub fn find_cycle( #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] #[non_exhaustive] -pub enum Colour { +pub(super) enum Colour { #[default] White, Grey, Black, } -pub fn depth_first_search<'a, N>( +pub(super) fn depth_first_search<'a, N>( graph: &'a Graph, colour_map: &mut HashMap, start_node_index: NodeIndex, diff --git a/src/sorting/validate.rs b/src/sorting/validate.rs index b8c54883..753d58b1 100644 --- a/src/sorting/validate.rs +++ b/src/sorting/validate.rs @@ -12,7 +12,7 @@ use super::{ plugins::{PluginSortingData, SortingPlugin}, }; -pub fn validate_plugin_groups( +pub(super) fn validate_plugin_groups( plugins_sorting_data: &[PluginSortingData<'_, T>], groups_graph: &GroupsGraph, ) -> Result<(), UndefinedGroupError> { @@ -30,7 +30,7 @@ pub fn validate_plugin_groups( Ok(()) } -pub fn validate_specific_and_hardcoded_edges( +pub(super) fn validate_specific_and_hardcoded_edges( masters: &[PluginSortingData<'_, T>], blueprint_masters: &[PluginSortingData<'_, T>], non_masters: &[PluginSortingData<'_, T>], diff --git a/src/tests.rs b/src/tests.rs index 96ecef30..8ddd8aa0 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -8,25 +8,25 @@ use crate::GameType; use parameterized_test::test_parameter; use tempfile::TempDir; -pub const BLANK_ESM: &str = "Blank.esm"; -pub const BLANK_DIFFERENT_ESM: &str = "Blank - Different.esm"; -pub const BLANK_MASTER_DEPENDENT_ESM: &str = "Blank - Master Dependent.esm"; +pub(crate) const BLANK_ESM: &str = "Blank.esm"; +pub(crate) const BLANK_DIFFERENT_ESM: &str = "Blank - Different.esm"; +pub(crate) const BLANK_MASTER_DEPENDENT_ESM: &str = "Blank - Master Dependent.esm"; const BLANK_DIFFERENT_MASTER_DEPENDENT_ESM: &str = "Blank - Different Master Dependent.esm"; -pub const BLANK_ESP: &str = "Blank.esp"; -pub const BLANK_DIFFERENT_ESP: &str = "Blank - Different.esp"; -pub const BLANK_MASTER_DEPENDENT_ESP: &str = "Blank - Master Dependent.esp"; +pub(crate) const BLANK_ESP: &str = "Blank.esp"; +pub(crate) const BLANK_DIFFERENT_ESP: &str = "Blank - Different.esp"; +pub(crate) const BLANK_MASTER_DEPENDENT_ESP: &str = "Blank - Master Dependent.esp"; const BLANK_DIFFERENT_MASTER_DEPENDENT_ESP: &str = "Blank - Different Master Dependent.esp"; const BLANK_PLUGIN_DEPENDENT_ESP: &str = "Blank - Plugin Dependent.esp"; const BLANK_DIFFERENT_PLUGIN_DEPENDENT_ESP: &str = "Blank - Different Plugin Dependent.esp"; -pub const BLANK_FULL_ESM: &str = "Blank.full.esm"; -pub const BLANK_MEDIUM_ESM: &str = "Blank.medium.esm"; -pub const BLANK_OVERRIDE_ESP: &str = "Blank - Override.esp"; -pub const BLANK_ESL: &str = "Blank.esl"; -pub const NON_PLUGIN_FILE: &str = "NotAPlugin.esm"; -pub const NON_ASCII_ESM: &str = "non\u{00C1}scii.esm"; +pub(crate) const BLANK_FULL_ESM: &str = "Blank.full.esm"; +pub(crate) const BLANK_MEDIUM_ESM: &str = "Blank.medium.esm"; +pub(crate) const BLANK_OVERRIDE_ESP: &str = "Blank - Override.esp"; +pub(crate) const BLANK_ESL: &str = "Blank.esl"; +pub(crate) const NON_PLUGIN_FILE: &str = "NotAPlugin.esm"; +pub(crate) const NON_ASCII_ESM: &str = "non\u{00C1}scii.esm"; -pub fn source_plugins_path(game_type: GameType) -> PathBuf { +pub(crate) fn source_plugins_path(game_type: GameType) -> PathBuf { match game_type { GameType::Morrowind | GameType::OpenMW => { absolute("./testing-plugins/Morrowind/Data Files") @@ -55,7 +55,7 @@ fn master_file(game_type: GameType) -> &'static str { } } -pub fn copy_file(source_dir: &Path, dest_dir: &Path, filename: &str) { +pub(crate) fn copy_file(source_dir: &Path, dest_dir: &Path, filename: &str) { copy(source_dir.join(filename), dest_dir.join(filename)).unwrap(); } @@ -81,7 +81,7 @@ fn is_load_order_timestamp_based(game_type: GameType) -> bool { ) } -pub fn initial_load_order(game_type: GameType) -> Vec<(&'static str, bool)> { +pub(crate) fn initial_load_order(game_type: GameType) -> Vec<(&'static str, bool)> { if game_type == GameType::Starfield { vec![ (master_file(game_type), true), @@ -176,7 +176,7 @@ fn data_path(game_type: GameType, game_path: &Path) -> PathBuf { } } -pub struct Fixture { +pub(crate) struct Fixture { _temp_dir: TempDir, pub(crate) game_type: GameType, pub(crate) game_path: PathBuf, @@ -184,7 +184,7 @@ pub struct Fixture { } impl Fixture { - pub fn new(game_type: GameType) -> Self { + pub(crate) fn new(game_type: GameType) -> Self { let temp_dir = tempfile::Builder::new() .prefix("libloot-t\u{00E9}st-") .tempdir() @@ -193,7 +193,7 @@ impl Fixture { Self::with_tempdir(game_type, temp_dir) } - pub fn in_path(game_type: GameType, in_path: &Path) -> Fixture { + pub(crate) fn in_path(game_type: GameType, in_path: &Path) -> Fixture { let temp_dir = tempfile::Builder::new() .prefix("libloot-t\u{00E9}st-") .tempdir_in(in_path) @@ -314,13 +314,13 @@ impl Fixture { } } - pub fn data_path(&self) -> PathBuf { + pub(crate) fn data_path(&self) -> PathBuf { data_path(self.game_type, &self.game_path) } } #[test_parameter] -pub const ALL_GAME_TYPES: [GameType; 12] = [ +pub(crate) const ALL_GAME_TYPES: [GameType; 12] = [ GameType::Oblivion, GameType::Skyrim, GameType::Fallout3,