Skip to content

Commit 6e854ec

Browse files
Peter554claude
andcommitted
Make internal types and functions private
Make implementation details private to reduce the public API surface: In filesystem.rs: - RealBasicFileSystem and FakeBasicFileSystem structs - Their inner fields - parse_indented_file_system_string function In import_scanning.rs: - py_found_packages_to_rust function - get_modules_from_found_packages function - scan_for_imports_no_py function - to_py_direct_imports function Only the Python-facing wrapper structs (PyRealBasicFileSystem, PyFakeBasicFileSystem) and the exported Python functions remain public. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c8e353a commit 6e854ec

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎rust/src/filesystem.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ pub trait FileSystem: Send + Sync {
3030

3131
#[derive(Clone)]
3232
#[pyclass]
33-
pub struct RealBasicFileSystem {}
33+
struct RealBasicFileSystem {}
3434

3535
// Implements a BasicFileSystem (defined in grimp.application.ports.filesystem.BasicFileSystem)
3636
// that actually reads files.
3737
#[pyclass(name = "RealBasicFileSystem")]
3838
pub struct PyRealBasicFileSystem {
39-
pub inner: RealBasicFileSystem,
39+
inner: RealBasicFileSystem,
4040
}
4141

4242
impl FileSystem for RealBasicFileSystem {
@@ -184,14 +184,14 @@ impl PyRealBasicFileSystem {
184184
type FileSystemContents = HashMap<String, String>;
185185

186186
#[derive(Clone)]
187-
pub struct FakeBasicFileSystem {
187+
struct FakeBasicFileSystem {
188188
contents: Arc<Mutex<FileSystemContents>>,
189189
}
190190

191191
// Implements BasicFileSystem (defined in grimp.application.ports.filesystem.BasicFileSystem).
192192
#[pyclass(name = "FakeBasicFileSystem")]
193193
pub struct PyFakeBasicFileSystem {
194-
pub inner: FakeBasicFileSystem,
194+
inner: FakeBasicFileSystem,
195195
}
196196

197197
impl FakeBasicFileSystem {
@@ -319,7 +319,7 @@ impl PyFakeBasicFileSystem {
319319
/// Parses an indented string representing a file system structure
320320
/// into a HashMap where keys are full file paths.
321321
/// See tests.adaptors.filesystem.FakeFileSystem for the API.
322-
pub fn parse_indented_file_system_string(file_system_string: &str) -> HashMap<String, String> {
322+
fn parse_indented_file_system_string(file_system_string: &str) -> HashMap<String, String> {
323323
let mut file_paths_map: HashMap<String, String> = HashMap::new();
324324
let mut path_stack: Vec<String> = Vec::new(); // Stores current directory path components
325325
let mut first_line = true; // Flag to handle the very first path component

‎rust/src/import_scanning.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<'py> FromPyObject<'py> for DirectImport {
3434
}
3535
}
3636

37-
pub fn py_found_packages_to_rust(py_found_packages: &Bound<'_, PyAny>) -> HashSet<FoundPackage> {
37+
fn py_found_packages_to_rust(py_found_packages: &Bound<'_, PyAny>) -> HashSet<FoundPackage> {
3838
let py_set = py_found_packages
3939
.downcast::<PySet>()
4040
.expect("Expected py_found_packages to be a Python set.");
@@ -52,7 +52,7 @@ pub fn py_found_packages_to_rust(py_found_packages: &Bound<'_, PyAny>) -> HashSe
5252
rust_found_packages
5353
}
5454

55-
pub fn get_modules_from_found_packages(found_packages: &HashSet<FoundPackage>) -> HashSet<Module> {
55+
fn get_modules_from_found_packages(found_packages: &HashSet<FoundPackage>) -> HashSet<Module> {
5656
let mut modules = HashSet::new();
5757
for package in found_packages {
5858
for module_file in &package.module_files {
@@ -73,7 +73,7 @@ fn module_is_descendant(module_name: &str, potential_ancestor: &str) -> bool {
7373
/// Statically analyses the given module and returns a set of Modules that
7474
/// it imports.
7575
#[allow(clippy::borrowed_box)]
76-
pub fn scan_for_imports_no_py(
76+
fn scan_for_imports_no_py(
7777
file_system: &Box<dyn FileSystem + Send + Sync>,
7878
found_packages: &HashSet<FoundPackage>,
7979
include_external_packages: bool,
@@ -169,7 +169,7 @@ fn scan_for_imports_no_py_single_module(
169169
Ok(imports)
170170
}
171171

172-
pub fn to_py_direct_imports<'a>(
172+
fn to_py_direct_imports<'a>(
173173
py: Python<'a>,
174174
rust_imports: &HashSet<DirectImport>,
175175
) -> Bound<'a, PySet> {

0 commit comments

Comments
 (0)