diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-07 19:22:21 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 2f214f6c9935e8ce8df4732cde44a540a003258c (patch) | |
| tree | 6fe319433ef0d2ad75fcc58a50eaa632bb627ec9 /rust/src/secrets_provider.rs | |
| parent | b4cf0be8816182c9efca037e27e9439482f8bf36 (diff) | |
[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.
Diffstat (limited to 'rust/src/secrets_provider.rs')
| -rw-r--r-- | rust/src/secrets_provider.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rust/src/secrets_provider.rs b/rust/src/secrets_provider.rs index 5924b9fb..a310b08e 100644 --- a/rust/src/secrets_provider.rs +++ b/rust/src/secrets_provider.rs @@ -49,7 +49,7 @@ impl CoreSecretsProvider { } /// Retrieve a provider by name - pub fn by_name<S: IntoCStr>(name: S) -> Option<CoreSecretsProvider> { + pub fn by_name(name: &str) -> Option<CoreSecretsProvider> { let name = name.to_cstr(); let result = unsafe { BNGetSecretsProviderByName(name.as_ptr()) }; NonNull::new(result).map(|h| unsafe { Self::from_raw(h) }) @@ -62,27 +62,27 @@ impl CoreSecretsProvider { } /// Check if data for a specific key exists, but do not retrieve it - pub fn has_data<S: IntoCStr>(&self, key: S) -> bool { + pub fn has_data(&self, key: &str) -> bool { let key = key.to_cstr(); unsafe { BNSecretsProviderHasData(self.handle.as_ptr(), key.as_ptr()) } } /// Retrieve data for the given key, if it exists - pub fn get_data<S: IntoCStr>(&self, key: S) -> String { + pub fn get_data(&self, key: &str) -> String { let key = key.to_cstr(); let result = unsafe { BNGetSecretsProviderData(self.handle.as_ptr(), key.as_ptr()) }; unsafe { BnString::into_string(result) } } /// Store data with the given key - pub fn store_data<K: IntoCStr, V: IntoCStr>(&self, key: K, value: V) -> bool { + pub fn store_data(&self, key: &str, value: &str) -> bool { let key = key.to_cstr(); let value = value.to_cstr(); unsafe { BNStoreSecretsProviderData(self.handle.as_ptr(), key.as_ptr(), value.as_ptr()) } } /// Delete stored data with the given key - pub fn delete_data<S: IntoCStr>(&self, key: S) -> bool { + pub fn delete_data(&self, key: &str) -> bool { let key = key.to_cstr(); unsafe { BNDeleteSecretsProviderData(self.handle.as_ptr(), key.as_ptr()) } } |
