From 2f214f6c9935e8ce8df4732cde44a540a003258c Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 7 May 2025 19:22:21 -0400 Subject: [Rust] Reduce usage of `IntoCStr` in function signatures This is being done to reduce complexity in function signatures, specifically many of the strings we are passing ultimately should be new types themselves instead of "just strings", things such as type ids. Another place which was confusing was dealing with filesystem related APIs, this commit turns most of those params into a stricter `Path` type. This is bringing the rust api more inline with both python and C++, where the wrapper eagerly converts the string into the languages standard string type. Special consideration must be made for symbols or other possible non utf-8 objects. This commit will be followed up with one that adds the `IntoCStr` bound on API's we want to keep as invalid utf-8 so we can for example, get section by name on a section with invalid utf-8. --- rust/src/render_layer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rust/src/render_layer.rs') diff --git a/rust/src/render_layer.rs b/rust/src/render_layer.rs index 3fd94a3a..08553552 100644 --- a/rust/src/render_layer.rs +++ b/rust/src/render_layer.rs @@ -61,8 +61,8 @@ impl Default for RenderLayerDefaultState { } /// Register a [`RenderLayer`] with the API. -pub fn register_render_layer( - name: S, +pub fn register_render_layer( + name: &str, render_layer: T, default_state: RenderLayerDefaultState, ) -> (&'static mut T, CoreRenderLayer) { @@ -299,7 +299,7 @@ impl CoreRenderLayer { unsafe { Array::new(result, count, ()) } } - pub fn render_layer_by_name(name: S) -> Option { + pub fn render_layer_by_name(name: &str) -> Option { let name_raw = name.to_cstr(); let result = unsafe { BNGetRenderLayerByName(name_raw.as_ptr()) }; NonNull::new(result).map(Self::from_raw) -- cgit v1.3.1