Crate apt_pkg_native [−] [src]
Here lies bindings to
libapt-pkg, which is what the
commands use to view and manipulate the state of packages on the system.
Currently, not much is exposed. You can pretty much only view basic package
information, like with
apt-cache policy foo.
libapt-pkg has basically no documentation.
python-apt is slightly better,
but is also pretty inconsistent on the documentation front. The design of this
crate is closer to
libapt-pkg, despite it being pretty insane.
The core concept here is an "iterator". Forget everything you know about iterators,
these iterators are pretty much pointers. The crate attempts to make them act
a bit more like Rust
Iterators, but is crippled by the insanity.
Methods which "find" something will reposition one of these "iterators" at the right place in an existing stream of items.
I recommend using
.map() to turn an "iterator" into a Rust type as soon as possible.
The returned map-like thing is a Rust
Iterator, so you can do normal operations on it.
Here's an example: normally you wouldn't need this ugly
.map(|_| ()) (read as "map anything
to the empty object"), but here, it is also converting a sh... apt "iterator" into a
extern crate apt_pkg_native; let mut cache = apt_pkg_native::Cache::get_singleton(); let total_packages = cache.iter().map(|_| ()).count();
libapt-pkg also just segfaults if you do anything wrong, or re-use anything at the wrong time,
or etc. I've tried to hide this, but I advise you not to push or outsmart the borrow checker.
Some structs representing basic concepts, and utilities to copy out of "iterators".
A reference to the package cache singleton, from which most functionality can be accessed.