diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-03 23:15:17 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 6264254065bbae9d89f51cf3330379b7ace09592 (patch) | |
| tree | 9ece1d1739215c2faef2d808ef4fdc019ad527fa /rust/src/collaboration/snapshot.rs | |
| parent | c3fdda9727f5507818e3f55576ad32215a22b0f9 (diff) | |
[Rust] Return `String` instead of `BnString` for cases where lossy conversion can be tolerated
Still need to go and audit all usage, but realistically the most important places to give the user control are with symbols, where the data can come from non utf8 sources
This is still incomplete, I just looked for usage of -> BnString so any other variant was omitted.
Diffstat (limited to 'rust/src/collaboration/snapshot.rs')
| -rw-r--r-- | rust/src/collaboration/snapshot.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/rust/src/collaboration/snapshot.rs b/rust/src/collaboration/snapshot.rs index 9f8f3693..935b1c2f 100644 --- a/rust/src/collaboration/snapshot.rs +++ b/rust/src/collaboration/snapshot.rs @@ -54,52 +54,52 @@ impl RemoteSnapshot { } /// Web api endpoint url - pub fn url(&self) -> BnString { + pub fn url(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetUrl(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Unique id - pub fn id(&self) -> BnString { + pub fn id(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetId(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Name of snapshot - pub fn name(&self) -> BnString { + pub fn name(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetName(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Get the title of a snapshot: the first line of its name - pub fn title(&self) -> BnString { + pub fn title(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetTitle(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Get the description of a snapshot: the lines of its name after the first line - pub fn description(&self) -> BnString { + pub fn description(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetDescription(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Get the user id of the author of a snapshot - pub fn author(&self) -> BnString { + pub fn author(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetAuthor(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Get the username of the author of a snapshot, if possible (vs author which is user id) - pub fn author_username(&self) -> BnString { + pub fn author_username(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetAuthorUsername(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Created date of Snapshot @@ -116,18 +116,18 @@ impl RemoteSnapshot { /// Hash of snapshot data (analysis and markup, etc) /// No specific hash algorithm is guaranteed - pub fn hash(&self) -> BnString { + pub fn hash(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetHash(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// Hash of file contents in snapshot /// No specific hash algorithm is guaranteed - pub fn snapshot_file_hash(&self) -> BnString { + pub fn snapshot_file_hash(&self) -> String { let value = unsafe { BNCollaborationSnapshotGetSnapshotFileHash(self.handle.as_ptr()) }; assert!(!value.is_null()); - unsafe { BnString::from_raw(value) } + unsafe { BnString::into_string(value) } } /// If the snapshot has pulled undo entries yet |
