nostrdb-rs

nostrdb in rust!
git clone git://jb55.com/nostrdb-rs
Log | Files | Refs | Submodules | README | LICENSE

commit 21d0002f5ff62e51c4114e3d15a2ffa4e99b17e8
parent c02f10cdad2cccb9f0927fdbac8c1fb89bcfeb2d
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 18 Dec 2023 17:18:19 -0800

ndb: remove mutability on transaction reference

It is unnecessary

Diffstat:
Msrc/ndb.rs | 8++++----
Msrc/note.rs | 8++++++++
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/ndb.rs b/src/ndb.rs @@ -80,7 +80,7 @@ impl Ndb { pub fn get_profile_by_pubkey<'a>( &self, - transaction: &'a mut Transaction, + transaction: &'a Transaction, id: &[u8; 32], ) -> Result<ProfileRecord<'a>> { let mut len: usize = 0; @@ -88,7 +88,7 @@ impl Ndb { let profile_record_ptr = unsafe { bindings::ndb_get_profile_by_pubkey( - transaction.as_mut_ptr(), + transaction.as_ptr() as *mut bindings::ndb_txn, id.as_ptr(), &mut len, &mut primkey, @@ -112,7 +112,7 @@ impl Ndb { /// Get a note from the database. Takes a [Transaction] and a 32-byte [Note] Id pub fn get_note_by_id<'a>( &self, - transaction: &'a mut Transaction, + transaction: &'a Transaction, id: &[u8; 32], ) -> Result<Note<'a>> { let mut len: usize = 0; @@ -120,7 +120,7 @@ impl Ndb { let note_ptr = unsafe { bindings::ndb_get_note_by_id( - transaction.as_mut_ptr(), + transaction.as_ptr() as *mut bindings::ndb_txn, id.as_ptr(), &mut len, &mut primkey, diff --git a/src/note.rs b/src/note.rs @@ -80,6 +80,14 @@ impl<'a> Note<'a> { } } + /// Get the note pubkey + pub fn pubkey(&self) -> &'a [u8; 32] { + unsafe { + let ptr = bindings::ndb_note_pubkey(self.as_ptr()); + &*(ptr as *const [u8; 32]) + } + } + pub fn kind(&self) -> u32 { unsafe { bindings::ndb_note_kind(self.as_ptr()) } }