[Rpm-maint] [rpm-software-management/rpm] Rust bindings for rpmlib (#429)

Tony Arcieri notifications at github.com
Sun Apr 15 16:05:43 UTC 2018


I've opened a PR which implements a bunch of @n3npq's suggestions:

https://github.com/iqlusion-io/crates/pull/28/files

Namely:

- No more `Database` type. Instead `db.rs` is a handful of static functions for querying the database
- `TransactionSet` is no-longer part of the public API (although it could be re-added in the future). Instead a mutex-guarded global transaction set is created the first time any function is invoked, and stored in a "lazy static". `rpmtsClean` is called immediately before releasing the global mutex.
- I've made my `Header` type take a reference with `headerLink` (and likewise call `headerFree` on drop). This let me switch from a `StreamingIterator` to a regular Rust `Iterator` like we were discussing, which is very nice.

All in all I think these changes make the API *much* more ergonomic:

### Before

```rust
let mut txn = Txn::create().unwrap();
let mut db = Database::open(&mut txn, false).unwrap();
let mut matches = db.find(Tag::NAME, "rpm-devel");
let headers = matches.next().unwrap();
```

### After

```rust
let mut matches = rpmlib::db::find(Tag::NAME, "rpm-devel");
let headers = matches.next().unwrap();
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/429#issuecomment-381417575
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20180415/f9f950f7/attachment.html>


More information about the Rpm-maint mailing list