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/database | |
| 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/database')
| -rw-r--r-- | rust/src/database/kvs.rs | 6 | ||||
| -rw-r--r-- | rust/src/database/snapshot.rs | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/rust/src/database/kvs.rs b/rust/src/database/kvs.rs index 5b7cbbe8..13b17962 100644 --- a/rust/src/database/kvs.rs +++ b/rust/src/database/kvs.rs @@ -41,7 +41,7 @@ impl KeyValueStore { } /// Get the value for a single key - pub fn value<S: IntoCStr>(&self, key: S) -> Option<DataBuffer> { + pub fn value(&self, key: &str) -> Option<DataBuffer> { let key_raw = key.to_cstr(); let key_ptr = key_raw.as_ptr(); let result = unsafe { BNGetKeyValueStoreBuffer(self.handle.as_ptr(), key_ptr) }; @@ -49,7 +49,7 @@ impl KeyValueStore { } /// Set the value for a single key - pub fn set_value<S: IntoCStr>(&self, key: S, value: &DataBuffer) -> bool { + pub fn set_value(&self, key: &str, value: &DataBuffer) -> bool { let key_raw = key.to_cstr(); let key_ptr = key_raw.as_ptr(); unsafe { BNSetKeyValueStoreBuffer(self.handle.as_ptr(), key_ptr, value.as_raw()) } @@ -63,7 +63,7 @@ impl KeyValueStore { } /// Begin storing new keys into a namespace - pub fn begin_namespace<S: IntoCStr>(&self, name: S) { + pub fn begin_namespace(&self, name: &str) { let name_raw = name.to_cstr(); let name_ptr = name_raw.as_ptr(); unsafe { BNBeginKeyValueStoreNamespace(self.handle.as_ptr(), name_ptr) } diff --git a/rust/src/database/snapshot.rs b/rust/src/database/snapshot.rs index d9ff030a..85c57f4e 100644 --- a/rust/src/database/snapshot.rs +++ b/rust/src/database/snapshot.rs @@ -50,7 +50,7 @@ impl Snapshot { } /// Set the displayed snapshot name - pub fn set_name<S: IntoCStr>(&self, value: S) { + pub fn set_name(&self, value: &str) { let value_raw = value.to_cstr(); let value_ptr = value_raw.as_ptr(); unsafe { BNSetSnapshotName(self.handle.as_ptr(), value_ptr) } |
