1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
//! Rust bindings to OpenSlide ([https://openslide.org/](https://openslide.org/)). //! //! This work has no affiliations with the official OpenSlide project. //! //! ## Requirements //! //! This library has been built for //! //! ```text,no-run //! OpenSlide 3.4.1 //! Rust 1.26 //! ``` //! //! I cannot guarantee that it works for other versions. //! //! ## Building OpenSlide //! //! Download the OpenSlide `3.4.1` from //! [https://openslide.org/download/](https://openslide.org/download/) //! to some location (here, `DOWNLOAD_DIR`) //! //! Build the project somewhere (here, `BUILD_DIR`): //! //! ```shell,no-run //! cd BUILD_DIR //! tar xvzf DOWNLOAD_DIR/openslide-3.4.1.tar.gz //! cd openslide-3.4.1 //! ./configure //! make //! sudo make install //! ``` //! //! In the build output, you will see something like this //! //! ```shell,no-run //! Libraries have been installed in: //! /usr/local/lib //! ``` //! //! To make the library discoverable, we append it (call it `LIB_DIR`) to the `LD_LIBRARY_PATH` //! environment variable //! //! ```shell,no-run //! export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:LIB_DIR //! ``` //! //! You should now be able to compile, and run a project using this OpenSlide binding. See the //! `examples` folder for examples. //! //! ## Interface //! //! This library provides both a *native* interface, and a more *convenient* interface. //! //! ### Native interface //! //! The native interface contains the raw bindings to the OpenSlide API, without any fluff. This //! interface should be close to the C interface in the original library, both with regards to function //! naming and documentation. This serves at least two purposes: //! //! 1: You can easily use the documentation for the C library //! 2: If you are not happy with my convenience wrappers, you could use this raw api to create your //! own. //! //! ```rust //! //! Example using the raw binding api //! //! extern crate failure; //! extern crate openslide; //! //! use failure::Error; //! use openslide::bindings; //! //! fn main() -> Result<(), Error> { //! let filename = "assets/CMU-1-Small-Region.svs"; //! let osr = bindings::open(filename)?; //! let num_levels = bindings::get_level_count(osr)?; //! println!("Slide has {} levels", num_levels); //! bindings::close(osr); //! //! Ok(()) //! } //! ``` //! //! Note that few or none assertions are made on correct use (like checking for valid number of levels //! or non-negative zoom factors). Also, as shown in the small example above, you have to close the //! slide explicitly. //! //! ### Convenience interface //! //! The convenience interface wraps the native interface and provides a more rust-like interface. These //! wrappings will enforce correct use via the type system and other checks. There is also no need to //! explicitly close an open slide, as the `OpenSlide` struct implements the `Drop` trait. //! //! ```rust //! //! Example using the convenience binding api //! //! extern crate failure; //! extern crate openslide; //! //! use std::path::Path; //! use failure::Error; //! use openslide::OpenSlide; //! //! fn main() -> Result<(), Error> { //! let filename = Path::new("assets/CMU-1-Small-Region.svs"); //! let os = openslide::OpenSlide::new(&filename)?; //! let num_levels = os.get_level_count()?; //! println!("Slide has {} levels", num_levels); //! //! Ok(()) //! } //! ``` //! extern crate libc; extern crate failure; extern crate image; /* pub use bindings::{OpenSlideT, detect_vendor, open, close, get_level_count, get_level0_dimensions, get_level_dimensions, get_level_downsample, get_best_level_for_downsample, read_region, get_error, get_property_names, get_property_value, }; */ pub use convenience::{OpenSlide, }; pub mod bindings; pub mod utils; mod convenience;