Skip to content

Commit

Permalink
Made exception related functions public
Browse files Browse the repository at this point in the history
cargo test passes
  • Loading branch information
nlfiedler committed Apr 18, 2019
1 parent 9f47958 commit 122f144
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This file follows the convention described at
[Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]
## [0.11.0] - 2019-04-17
### Changed
- Updated `bindgen` dependency to 0.31 release and fixed compiler issues.
Enum definitions changed again, default in bindgen is different now, and
using `default_enum_style()` caused endless compiler errors.
- Made `get_exception_type()`, `get_exception()`, and `clear_exception()`
on the various wand implementations.

## [0.10.0] - 2018-08-11
### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "magick_rust"
version = "0.10.0"
version = "0.11.0"
authors = ["Nathan Fiedler <[email protected]>"]
description = "Selection of Rust bindings for the ImageMagick library."
homepage = "https://github.com/nlfiedler/magick-rust"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A somewhat safe Rust interface to the [ImageMagick](http://www.imagemagick.org/)
- Linux may require building ImageMagick from source, see the `Dockerfile` for an example
- Windows: download `*-dll` [installer](https://www.imagemagick.org/script/download.php#windows). Only MSVC version available. When installing, check the checkbox "Install development headers and libraries for C and C++".
* [Clang](https://clang.llvm.org) (version 3.5 or higher)
- Or whatever version is dictated by [rust-bindgen](https://github.com/servo/rust-bindgen)
- Or whatever version is dictated by [rust-bindgen](https://github.com/rust-lang/rust-bindgen)
* Windows requires MSVC toolchain
* Optionally `pkg-config`, to facilitate linking with ImageMagick. Or you can set linker parameters via environment variables.

Expand Down Expand Up @@ -69,6 +69,10 @@ fn resize() -> Result<Vec<u8>, &'static str> {

Writing the image to a file rather than an in-memory blob is done by replacing the call to `write_image_blob()` with `write_image()`, which takes a string for the path to the file.

## Frequent API Changes

Because rust-bindgen changes from time to time, and is very difficult to use for a library as large as ImageMagick, the API of this crate may experience dramatic mood swings. Typically this pain manifests itself in the way the enums are represented. I am deeply sorry for this pain. Hopefully someone smarter than me can fix it some day. Pull requests are welcome.

## Contributing

There are still many missing functions, so if you find there is something you would like to see added to this library, feel free to file an issue. Even better, fork the repo, and write the thin wrapper necessary to expose the MagickWand function. For getters and setters this is often very easy, just add a row to the table in `wand/magick.rs`, and it will work with no additional coding. Tests are optional, as this crate is basically a thin wrapper around code that is assumed to be thoroughly tested already. If you make a change that you want to contribute, please feel free to submit a pull request.
Expand Down
6 changes: 3 additions & 3 deletions src/wand/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ macro_rules! wand_common {
unsafe { ::bindings::$clear_wand(self.wand) }
}

fn clear_exception(&mut self) -> Result<(), &'static str> {
pub fn clear_exception(&mut self) -> Result<(), &'static str> {
match unsafe { ::bindings::$clear_exc(self.wand) } {
::bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(concat!("failed to clear", stringify!($wand), "exception")),
}
}

fn get_exception_type(&self) -> ::bindings::ExceptionType {
pub fn get_exception_type(&self) -> ::bindings::ExceptionType {
unsafe { ::bindings::$get_exc_type(self.wand) }
}

fn get_exception(&self) -> Result<(String, ::bindings::ExceptionType), &'static str> {
pub fn get_exception(&self) -> Result<(String, ::bindings::ExceptionType), &'static str> {
let mut severity: ::bindings::ExceptionType =
::bindings::ExceptionType_UndefinedException;
// TODO: memory management
Expand Down

0 comments on commit 122f144

Please sign in to comment.