Skip to content

Commit

Permalink
Updates to dependencies, MSRV, and language edition
Browse files Browse the repository at this point in the history
  • Loading branch information
felixc committed Jul 30, 2022
1 parent 93ec4ff commit 9318b79
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 56 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2022-07-30 - v1.2.0
* Internal dependency updates.
* Adopt 2021 language edition.
* Change minimum supported rustc version to 1.56.

2020-07-12 - v1.1.2
* Internal dependency upgrades.

Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[package]
name = "gexiv2-sys"
description = """
This library provides Rust FFI declarations for the gexiv2 library, which
is a GObject-based wrapper around the Exiv2 library, which provides read
and write access to the Exif, XMP, and IPTC metadata in media files. Only
FFI declarations are provided here; for a usable Rust library, consider
the `rexiv2` crate.
This crate provides Rust FFI declarations for the gexiv2 library, which is a
GObject-based wrapper around Exiv2, which provides read and write access to the
Exif, XMP, and IPTC metadata in media files. Only FFI declarations are provided
here; for a usable Rust library, consider the `rexiv2` crate.
"""

version = "1.1.2"
version = "1.2.0"
authors = ["Felix Crux <[email protected]>"]
license = "GPL-3.0+"
documentation = "https://felixcrux.com/files/doc/gexiv2_sys/"
Expand All @@ -20,7 +19,8 @@ readme = "README.md"
links = "gexiv2"
build = "build.rs"

edition = "2018"
edition = "2021"
rust-version = "1.56"

include = [
"Cargo.toml",
Expand All @@ -34,14 +34,14 @@ include = [

[dependencies]
libc = "0.2"
bitflags = { version = "1.0", optional = true}
glib-sys = { version = "0.10", optional = true }
bitflags = { version = "1.3", optional = true}
glib-sys = { version = "0.15", optional = true }

[build-dependencies]
pkg-config = "0.3"

[dev-dependencies]
tempdir = "0.3"
tempfile = "3.3"

[features]
raw-tag-access = ["glib-sys"]
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ gexiv2-sys
Rust FFI declarations for gexiv2
--------------------------------

This library provides Rust FFI declarations for the [gexiv2][gexiv2] library,
which is a GObject-based wrapper around the [Exiv2][exiv2] library, which
provides read and write access to the Exif, XMP, and IPTC metadata in media
files.
This crate provides Rust FFI declarations for the [gexiv2][gexiv2] library,
which is a GObject-based wrapper around [Exiv2][exiv2], which provides read and
write access to the Exif, XMP, and IPTC metadata in media files.

Only FFI declarations are provided here; **for a usable Rust library, consider
the [rexiv2][rexiv2] crate**.
Expand Down Expand Up @@ -58,8 +57,7 @@ Given that it links to gexiv2, and transitively to Exiv2, gexiv2-sys obviously
depends on them. These libraries are not bundled with gexiv2-sys: you will need
to install them separately.

The oldest supported `rustc` compiler is the 1.31 version, with the 2018 edition
of the language.
The minimum supported `rustc` version is 1.56.

For full instructions on how to get started with gexiv2-sys, including how to
install the prerequisite dependencies, refer to the [`SETUP`](SETUP.md) file.
Expand Down
37 changes: 5 additions & 32 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ this by adding a dependency on gexiv2-sys in your crate’s `Cargo.toml` file:

```toml
[dependencies]
gexiv2-sys = "0.7"
gexiv2-sys = "1.2"
libc = "0.2"
```

Expand All @@ -104,7 +104,7 @@ most likely need it in order to do anything useful with gexiv2-sys).
To enable one of the optional features of the crate, specify it as follows:

```toml
gexiv2-sys = { version = "0.7", features = ["raw-tag-access"] }
gexiv2-sys = { version = "1.2", features = ["raw-tag-access"] }
```

Alternatively, if you’d like to work off of the bleeding edge (note that this is
Expand All @@ -121,38 +121,11 @@ or on a local copy, using the `path` option:
gexiv2-sys = { path = "../gexiv2-sys" } # Or wherever your copy is located
```

Now you can import and use the functions defined in gexiv2-sys like this:
Now you can import and use the functions defined in gexiv2-sys. Check the
[`examples` directory][examples] for sample code.

```rust
extern crate gexiv2_sys as gexiv2;
extern crate libc;

use std::ffi;
use std::ptr;

fn main() {
unsafe {
let metadata = gexiv2::gexiv2_metadata_new();
let mut err: *mut gexiv2::GError = ptr::null_mut();
let path = ffi::CString::new("example.jpg").unwrap();

let ok = gexiv2::gexiv2_metadata_open_path(
metadata, path.as_ptr(), &mut err);
if ok != 1 {
match ffi::CStr::from_ptr((*err).message).to_str() {
Ok(v) => panic!(v.to_owned()),
Err(_) => panic!("Unknown error".to_owned())
}
}

let c_str = gexiv2::gexiv2_metadata_get_mime_type(metadata);
println!("{:?}", ffi::CStr::from_ptr(c_str).to_str());

gexiv2::gexiv2_metadata_free(metadata);
}
}
```

[crates-gexiv2-sys]: https://crates.io/crates/gexiv2-sys
[crates-libc]: https://crates.io/crates/libc
[rexiv2]: https://github.com/felixc/rexiv2
[examples]: https://github.com/felixc/gexiv2-sys/tree/main/examples
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2015 Felix A. Crux <[email protected]>
// Copyright © 2015-2022 Felix A. Crux <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -25,7 +25,7 @@ fn main() {
"\nThe gexiv2 library was not found by pkg-config on your system.\n\n\
Consult the README.md file for suggestions on how to acquire it."
);
panic!(e);
panic!("{}", e);
}
}
}
2 changes: 1 addition & 1 deletion examples/open_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub unsafe fn make_new_metadata() -> *mut gexiv2::GExiv2Metadata {
);
if ok != 1 {
match ffi::CStr::from_ptr((*err).message).to_str() {
Ok(v) => panic!(v.to_string()),
Ok(v) => panic!("{}", v.to_string()),
Err(_) => panic!("Unknown error"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2015–2019 Felix A. Crux <[email protected]> and contributors
// Copyright © 2015–2022 Felix A. Crux <[email protected]> and contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
8 changes: 4 additions & 4 deletions src/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017-2019 Felix A. Crux <[email protected]> and contributors
// Copyright © 2017-2022 Felix A. Crux <[email protected]> and contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,7 @@
//! Basic tests for gexiv2.

extern crate libc;
extern crate tempdir;
extern crate tempfile;

use std::ffi;
use std::fs;
Expand Down Expand Up @@ -47,7 +47,7 @@ unsafe fn make_new_metadata() -> *mut GExiv2Metadata {
);
if ok != 1 {
match ffi::CStr::from_ptr((*err).message).to_str() {
Ok(v) => panic!(v.to_string()),
Ok(v) => panic!("{}", v.to_string()),
Err(_) => panic!("Unknown error"),
}
}
Expand Down Expand Up @@ -223,7 +223,7 @@ fn metadata_set_exif_thumbnail_from_file() {
unsafe {
let meta = make_new_metadata();

let tmp_dir = tempdir::TempDir::new("gexiv2_sys_tests").unwrap();
let tmp_dir = tempfile::tempdir().unwrap();
let tmp_file_path = tmp_dir.path().join("thumb.jpg");
let mut thumb_file = fs::File::create(tmp_file_path.clone()).unwrap();
thumb_file.write_all(MINI_JPEG).unwrap();
Expand Down

0 comments on commit 9318b79

Please sign in to comment.