(Note: I’ve crossposted this on the subreddit because I’m not sure where discussions like this are happening/should happen. If people feel this is spammy I’ll gladly delete one or the other post)
I’m fairly new to Rust, so to help me learn the language I decided to build some photography workflow tools for myself in the language. The first thing I needed was a library to enable read/write access to the metadata stored in media files (Exif, XMP, and IPTC).
rexiv2 is my library for doing this. It’s a Rust wrapper around the gexiv2 library, which is itself a GObject-based wrapper around the Exiv2 library, which provides what we need. This is the same metadata library used by Gimp and Shotwell. I’ve just pushed to GitHub a version 0.1.0-pre unstable preview that I believe provides all of the necessary basic functionality, albeit in a potentially un-ergonomic, un-Rust-like, rough kind of way.
Seeing as how I’m very new to the language, I’d really appreciate feedback/suggestions on anything and everything: coding style, API conventions, wasteful or inefficient copies/allocations that I’m doing, potential FFI mistakes… everything!
I also have some specific questions:
How should one pass an array of strings to a C FFI function? You can see how I received one in the
get_tag_multiple_stringsmethod, but I’m not sure how to do the inverse in
What should APIs return,
&str? I think I grasp the distinction, and I see why it makes sense to consume
&strs, but is it possible to do the same thing with what you return? I ran into problems with lifetimes.
Are the stability attributes used in the core language/standard library meant for use by libraries like this as well? Should I be tagging things unstable? Is that worthwhile given the version number?
Building through Cargo already informs rustc and rustdoc that this is a
libtype crate, and that it’s called rexiv2. What are the
#![crate_type = lib]and
crate_nameannotations for? Should they be there?
What’s the best practice for third-party library dependencies? My Linux package management background strongly protests against bundling the source, but making users go elsewhere to download and install stuff isn’t great either. Should
build.rslook for the libraries and print a message? Attempt to download them? Fetch the source and build them?
Thank you also to all the folks on IRC who helped out with my beginner questions!