Migrate to Rust 2018.
This commit is contained in:
parent
56106534cd
commit
eb4723a8a9
|
@ -2,6 +2,7 @@
|
||||||
name = "exif"
|
name = "exif"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
authors = ["KAMADA Ken'ichi <kamada@nanohz.org>"]
|
authors = ["KAMADA Ken'ichi <kamada@nanohz.org>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
description = "Exif parsing library written in pure Rust"
|
description = "Exif parsing library written in pure Rust"
|
||||||
documentation = "https://docs.rs/kamadak-exif"
|
documentation = "https://docs.rs/kamadak-exif"
|
||||||
|
|
2
README
2
README
|
@ -15,7 +15,7 @@ Usage
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kamadak-exif = "0.3"
|
kamadak-exif = "0.3"
|
||||||
|
|
||||||
Add the following to your crate root.
|
Add the following to your crate root (before Rust 2018).
|
||||||
|
|
||||||
extern crate exif;
|
extern crate exif;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use util::read8;
|
use crate::util::{read8, read16};
|
||||||
use util::read16;
|
|
||||||
|
|
||||||
mod marker {
|
mod marker {
|
||||||
// The first byte of a marker.
|
// The first byte of a marker.
|
||||||
|
|
|
@ -62,7 +62,7 @@ pub use value::{Rational, SRational};
|
||||||
|
|
||||||
/// The interfaces in this module are experimental and unstable.
|
/// The interfaces in this module are experimental and unstable.
|
||||||
pub mod experimental {
|
pub mod experimental {
|
||||||
pub use writer::Writer;
|
pub use crate::writer::Writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -29,11 +29,11 @@ use std::io;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use jpeg;
|
use crate::jpeg;
|
||||||
use tag::Tag;
|
use crate::tag::Tag;
|
||||||
use tiff;
|
use crate::tiff;
|
||||||
use tiff::Field;
|
use crate::tiff::Field;
|
||||||
|
|
||||||
/// The `Reader` struct reads a JPEG or TIFF image,
|
/// The `Reader` struct reads a JPEG or TIFF image,
|
||||||
/// parses the Exif attributes in it, and holds the results.
|
/// parses the Exif attributes in it, and holds the results.
|
||||||
|
@ -130,7 +130,7 @@ impl Reader {
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use value::Value;
|
use crate::value::Value;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
static TIFF_ASCII: &'static [u8] =
|
static TIFF_ASCII: &'static [u8] =
|
||||||
|
|
12
src/tag.rs
12
src/tag.rs
|
@ -26,9 +26,9 @@
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use value;
|
use crate::value;
|
||||||
use value::Value;
|
use crate::value::Value;
|
||||||
use util::atou16;
|
use crate::util::atou16;
|
||||||
|
|
||||||
/// A tag of a TIFF field.
|
/// A tag of a TIFF field.
|
||||||
///
|
///
|
||||||
|
@ -144,8 +144,8 @@ macro_rules! generate_well_known_tag_constants {
|
||||||
|
|
||||||
mod tag_info {
|
mod tag_info {
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use value::Value;
|
use crate::value::Value;
|
||||||
use value::DefaultValue;
|
use crate::value::DefaultValue;
|
||||||
|
|
||||||
pub struct TagInfo {
|
pub struct TagInfo {
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
|
@ -583,7 +583,7 @@ fn d_resunit(w: &mut fmt::Write, value: &Value) -> fmt::Result {
|
||||||
fn d_datetime(w: &mut fmt::Write, value: &Value) -> fmt::Result {
|
fn d_datetime(w: &mut fmt::Write, value: &Value) -> fmt::Result {
|
||||||
if let Value::Ascii(ref v) = *value {
|
if let Value::Ascii(ref v) = *value {
|
||||||
if let Some(dt) = v.first() {
|
if let Some(dt) = v.first() {
|
||||||
if let Ok(dt) = ::tiff::DateTime::from_ascii(dt) {
|
if let Ok(dt) = crate::tiff::DateTime::from_ascii(dt) {
|
||||||
return write!(w, "{}", dt)
|
return write!(w, "{}", dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
src/tiff.rs
12
src/tiff.rs
|
@ -26,12 +26,12 @@
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use endian::{Endian, BigEndian, LittleEndian};
|
use crate::endian::{Endian, BigEndian, LittleEndian};
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use tag::{Context, Tag};
|
use crate::tag::{Context, Tag};
|
||||||
use value::Value;
|
use crate::value::Value;
|
||||||
use value::get_type_info;
|
use crate::value::get_type_info;
|
||||||
use util::{atou16, ctou32};
|
use crate::util::{atou16, ctou32};
|
||||||
|
|
||||||
// TIFF header magic numbers [EXIF23 4.5.2].
|
// TIFF header magic numbers [EXIF23 4.5.2].
|
||||||
const TIFF_BE: u16 = 0x4d4d;
|
const TIFF_BE: u16 = 0x4d4d;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
const ASCII_0: u8 = 0x30;
|
const ASCII_0: u8 = 0x30;
|
||||||
const ASCII_9: u8 = 0x39;
|
const ASCII_9: u8 = 0x39;
|
||||||
|
|
12
src/value.rs
12
src/value.rs
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use endian::Endian;
|
use crate::endian::Endian;
|
||||||
|
|
||||||
/// Types and values of TIFF fields (for Exif attributes).
|
/// Types and values of TIFF fields (for Exif attributes).
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -89,8 +89,8 @@ impl<'a> Value<'a> {
|
||||||
/// "pixels per inch");
|
/// "pixels per inch");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn display_as(&self, tag: ::tag::Tag) -> Display {
|
pub fn display_as(&self, tag: crate::tag::Tag) -> Display {
|
||||||
::tag::display_value_as(self, tag)
|
crate::tag::display_value_as(self, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the unsigned integer at the given position.
|
/// Returns the unsigned integer at the given position.
|
||||||
|
@ -427,7 +427,7 @@ fn parse_unknown<'a>(data: &'a [u8], offset: usize, count: usize)
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use endian::BigEndian;
|
use crate::endian::BigEndian;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -621,7 +621,7 @@ mod tests {
|
||||||
let sets: &[(&[u8], Vec<f32>)] = &[
|
let sets: &[(&[u8], Vec<f32>)] = &[
|
||||||
(b"x", vec![]),
|
(b"x", vec![]),
|
||||||
(b"x\x7f\x7f\xff\xff\x80\x80\x00\x00\x40\x00\x00\x00",
|
(b"x\x7f\x7f\xff\xff\x80\x80\x00\x00\x40\x00\x00\x00",
|
||||||
vec![::std::f32::MAX, -::std::f32::MIN_POSITIVE, 2.0]),
|
vec![std::f32::MAX, -std::f32::MIN_POSITIVE, 2.0]),
|
||||||
];
|
];
|
||||||
let (unitlen, parser) = get_type_info::<BigEndian>(11);
|
let (unitlen, parser) = get_type_info::<BigEndian>(11);
|
||||||
for &(data, ref ans) in sets {
|
for &(data, ref ans) in sets {
|
||||||
|
@ -640,7 +640,7 @@ mod tests {
|
||||||
(b"x\x7f\xef\xff\xff\xff\xff\xff\xff\
|
(b"x\x7f\xef\xff\xff\xff\xff\xff\xff\
|
||||||
\x80\x10\x00\x00\x00\x00\x00\x00\
|
\x80\x10\x00\x00\x00\x00\x00\x00\
|
||||||
\x40\x00\x00\x00\x00\x00\x00\x00",
|
\x40\x00\x00\x00\x00\x00\x00\x00",
|
||||||
vec![::std::f64::MAX, -::std::f64::MIN_POSITIVE, 2.0]),
|
vec![std::f64::MAX, -std::f64::MIN_POSITIVE, 2.0]),
|
||||||
];
|
];
|
||||||
let (unitlen, parser) = get_type_info::<BigEndian>(12);
|
let (unitlen, parser) = get_type_info::<BigEndian>(12);
|
||||||
for &(data, ref ans) in sets {
|
for &(data, ref ans) in sets {
|
||||||
|
|
|
@ -27,11 +27,11 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{Seek, SeekFrom, Write};
|
use std::io::{Seek, SeekFrom, Write};
|
||||||
|
|
||||||
use endian::{Endian, BigEndian, LittleEndian};
|
use crate::endian::{Endian, BigEndian, LittleEndian};
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
use tag::{Context, Tag};
|
use crate::tag::{Context, Tag};
|
||||||
use tiff::{Field, TIFF_BE_SIG, TIFF_LE_SIG};
|
use crate::tiff::{Field, TIFF_BE_SIG, TIFF_LE_SIG};
|
||||||
use value::Value;
|
use crate::value::Value;
|
||||||
|
|
||||||
/// The `Writer` struct is used to encode and write Exif data.
|
/// The `Writer` struct is used to encode and write Exif data.
|
||||||
///
|
///
|
||||||
|
@ -609,7 +609,7 @@ fn get_offset<W>(w: &mut W)
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use value::{Rational, SRational};
|
use crate::value::{Rational, SRational};
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue