Skip to content

Commit

Permalink
note: add method for getting note content
Browse files Browse the repository at this point in the history
  • Loading branch information
jb55 committed Dec 17, 2023
1 parent cb1c768 commit 892a395
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ impl<'a> Note<'a> {
}
}

fn content_size(&self) -> usize {
unsafe { bindings::ndb_note_content_length(self.as_ptr()) as usize }
}

/// Get the [`Note`] contents.
pub fn content(&self) -> &'a str {
unsafe {
let content = bindings::ndb_note_content(self.as_ptr());
let byte_slice = std::slice::from_raw_parts(content as *const u8, self.content_size());
std::str::from_utf8_unchecked(byte_slice)
}
}

pub fn kind(&self) -> u32 {
unsafe { bindings::ndb_note_kind(self.as_ptr()) }
}
Expand Down

0 comments on commit 892a395

Please sign in to comment.