@@ -54,8 +54,24 @@ impl Default for PythonImporterState {
54
54
}
55
55
56
56
impl PythonImporterState {
57
+ /// Load state from the environment and by parsing data structures.
58
+ pub fn load (
59
+ & mut self ,
60
+ modules_data : & ' static [ u8 ] ,
61
+ resources_data : & ' static [ u8 ] ,
62
+ ) -> Result < ( ) , & ' static str > {
63
+ // Last write wins. So start with core modules then move on to more
64
+ // local data.
65
+ self . load_interpreter_builtin_modules ( ) ?;
66
+ self . load_interpreter_frozen_modules ( ) ?;
67
+ self . load_modules_data ( modules_data) ?;
68
+ self . load_resources_data ( resources_data) ?;
69
+
70
+ Ok ( ( ) )
71
+ }
72
+
57
73
/// Load `builtin` modules from the Python interpreter.
58
- pub fn load_interpreter_builtin_modules ( & mut self ) -> Result < ( ) , & ' static str > {
74
+ fn load_interpreter_builtin_modules ( & mut self ) -> Result < ( ) , & ' static str > {
59
75
for i in 0 .. {
60
76
let record = unsafe { pyffi:: PyImport_Inittab . offset ( i) } ;
61
77
@@ -78,7 +94,7 @@ impl PythonImporterState {
78
94
}
79
95
80
96
/// Load `frozen` modules from the Python interpreter.
81
- pub fn load_interpreter_frozen_modules ( & mut self ) -> Result < ( ) , & ' static str > {
97
+ fn load_interpreter_frozen_modules ( & mut self ) -> Result < ( ) , & ' static str > {
82
98
for i in 0 .. {
83
99
let record = unsafe { pyffi:: PyImport_FrozenModules . offset ( i) } ;
84
100
@@ -101,7 +117,7 @@ impl PythonImporterState {
101
117
}
102
118
103
119
/// Parse binary modules data and update current data structure.
104
- pub fn load_modules_data ( & mut self , data : & ' static [ u8 ] ) -> Result < ( ) , & ' static str > {
120
+ fn load_modules_data ( & mut self , data : & ' static [ u8 ] ) -> Result < ( ) , & ' static str > {
105
121
let mut reader = Cursor :: new ( data) ;
106
122
107
123
let count = reader
@@ -196,7 +212,7 @@ impl PythonImporterState {
196
212
Ok ( ( ) )
197
213
}
198
214
199
- pub fn load_resources_data ( & mut self , data : & ' static [ u8 ] ) -> Result < ( ) , & ' static str > {
215
+ fn load_resources_data ( & mut self , data : & ' static [ u8 ] ) -> Result < ( ) , & ' static str > {
200
216
let mut reader = Cursor :: new ( data) ;
201
217
202
218
let package_count = reader
0 commit comments