Skip to content

Commit 6135996

Browse files
committed
[Rust] Support owned settings handles
1 parent bff65fa commit 6135996

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

rust/src/settings.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ pub struct Settings {
3535
}
3636

3737
impl Settings {
38+
pub(crate) unsafe fn from_raw(handle: *mut BNSettings) -> Self {
39+
Self { handle }
40+
}
41+
3842
pub(crate) unsafe fn ref_from_raw(handle: *mut BNSettings) -> Ref<Self> {
3943
debug_assert!(!handle.is_null());
4044
Ref::new(Self { handle })
@@ -517,11 +521,11 @@ impl Settings {
517521
unsafe { BNSettingsRegisterGroup(self.handle, group.as_ptr(), title.as_ptr()) }
518522
}
519523

520-
pub fn register_setting_json(&self, group: &str, properties: &str) -> bool {
521-
let group = group.to_cstr();
524+
pub fn register_setting_json(&self, key: &str, properties: &str) -> bool {
525+
let key = key.to_cstr();
522526
let properties = properties.to_cstr();
523527

524-
unsafe { BNSettingsRegisterSetting(self.handle, group.as_ptr(), properties.as_ptr()) }
528+
unsafe { BNSettingsRegisterSetting(self.handle, key.as_ptr(), properties.as_ptr()) }
525529
}
526530

527531
// TODO: register_setting but type-safely turn it into json

0 commit comments

Comments
 (0)