@@ -37,9 +37,10 @@ impl Core {
37
37
38
38
/// Construct a new OpenVINO [`Core`] with config specified in an xml file.
39
39
pub fn new_with_config ( xml_config_file : & str ) -> std:: result:: Result < Core , SetupError > {
40
+ let xml_config_file = cstr ! ( xml_config_file) ;
40
41
let mut ptr = std:: ptr:: null_mut ( ) ;
41
42
try_unsafe ! ( ov_core_create_with_config(
42
- cstr! ( xml_config_file. to_string ( ) ) ,
43
+ xml_config_file. as_ptr ( ) ,
43
44
std:: ptr:: addr_of_mut!( ptr)
44
45
) ) ?;
45
46
Ok ( Core { ptr } )
@@ -56,7 +57,7 @@ impl Core {
56
57
} ;
57
58
try_unsafe ! ( ov_core_get_versions_by_device_name(
58
59
self . ptr,
59
- device_name,
60
+ device_name. as_ptr ( ) ,
60
61
std:: ptr:: addr_of_mut!( ov_version_list)
61
62
) ) ?;
62
63
@@ -110,7 +111,7 @@ impl Core {
110
111
try_unsafe ! ( ov_core_get_property(
111
112
self . ptr,
112
113
EMPTY_C_STR . as_ptr( ) ,
113
- ov_prop_key,
114
+ ov_prop_key. as_ptr ( ) ,
114
115
std:: ptr:: addr_of_mut!( ov_prop_value)
115
116
) ) ?;
116
117
let rust_prop = unsafe { CStr :: from_ptr ( ov_prop_value) }
@@ -127,8 +128,8 @@ impl Core {
127
128
try_unsafe ! ( ov_core_set_property(
128
129
self . ptr,
129
130
EMPTY_C_STR . as_ptr( ) ,
130
- ov_prop_key,
131
- ov_prop_value,
131
+ ov_prop_key. as_ptr ( ) ,
132
+ ov_prop_value. as_ptr ( ) ,
132
133
) ) ?;
133
134
Ok ( ( ) )
134
135
}
@@ -152,8 +153,8 @@ impl Core {
152
153
let mut ov_prop_value = std:: ptr:: null_mut ( ) ;
153
154
try_unsafe ! ( ov_core_get_property(
154
155
self . ptr,
155
- ov_device_name,
156
- ov_prop_key,
156
+ ov_device_name. as_ptr ( ) ,
157
+ ov_prop_key. as_ptr ( ) ,
157
158
std:: ptr:: addr_of_mut!( ov_prop_value)
158
159
) ) ?;
159
160
let rust_prop = unsafe { CStr :: from_ptr ( ov_prop_value) }
@@ -175,9 +176,9 @@ impl Core {
175
176
let ov_prop_value = cstr ! ( value) ;
176
177
try_unsafe ! ( ov_core_set_property(
177
178
self . ptr,
178
- ov_device_name,
179
- ov_prop_key,
180
- ov_prop_value,
179
+ ov_device_name. as_ptr ( ) ,
180
+ ov_prop_key. as_ptr ( ) ,
181
+ ov_prop_value. as_ptr ( ) ,
181
182
) ) ?;
182
183
Ok ( ( ) )
183
184
}
@@ -197,11 +198,13 @@ impl Core {
197
198
/// Read a Model from a pair of files: `model_path` points to an XML file containing the
198
199
/// OpenVINO model IR and `weights_path` points to the binary weights file.
199
200
pub fn read_model_from_file ( & mut self , model_path : & str , weights_path : & str ) -> Result < Model > {
201
+ let model_path = cstr ! ( model_path) ;
202
+ let weights_path = cstr ! ( weights_path) ;
200
203
let mut ptr = std:: ptr:: null_mut ( ) ;
201
204
try_unsafe ! ( ov_core_read_model(
202
205
self . ptr,
203
- cstr! ( model_path) ,
204
- cstr! ( weights_path) ,
206
+ model_path. as_ptr ( ) ,
207
+ weights_path. as_ptr ( ) ,
205
208
std:: ptr:: addr_of_mut!( ptr)
206
209
) ) ?;
207
210
Ok ( Model :: from_ptr ( ptr) )
0 commit comments