Commit Graph

52 Commits

Author SHA1 Message Date
Michael Pfaff a6461ef7d5
Improve 2021-05-28 13:48:05 -04:00
KAMADA Ken'ichi 8232c6cd51 Deprecate impl From<{Rational,SRational}> for {f64,f32}.
The #[deprecated] attribute does not work on impl items, so
comments have been added.
2021-05-04 22:12:47 +09:00
KAMADA Ken'ichi 8a9e10de60 Add Rational::to_f32 and SRational::to_f32. 2021-05-04 21:54:44 +09:00
KAMADA Ken'ichi da36010bb9 Update documentation. 2021-03-21 17:56:37 +09:00
KAMADA Ken'ichi 663a24de79 Try a new API set internally for Value access. 2020-02-15 19:07:58 +09:00
KAMADA Ken'ichi 79cc94f615 More readable Debug::fmt for Value::{Ascii, Undefined}. 2020-02-05 23:05:48 +09:00
KAMADA Ken'ichi faefc75601 Use iter() instead of into_iter() where appropriate. 2020-01-08 22:52:44 +09:00
KAMADA Ken'ichi fa34bc9895 Derive Clone trait for Value and Field. 2019-12-15 21:11:20 +09:00
KAMADA Ken'ichi 1bd083cbae Do not reference the raw buffer from Value and Field.
Previously, they borrowed the buffer, so users had some difficulty to
manage the lifetime of the buffer and Value/Field.  For example,
a user structure was unable to contain both the buffer and a Field.
2019-12-14 21:57:35 +09:00
KAMADA Ken'ichi 1533be5a2a Mark trait objects explicitly with dyn. 2019-10-21 23:53:43 +09:00
KAMADA Ken'ichi 6c3ddddc96 Remove an empty line. 2019-04-13 19:45:00 +09:00
KAMADA Ken'ichi e1e4800eea Implement From<(u32, u32)> for Rational and i32 version for SRational. 2019-04-12 23:35:28 +09:00
KAMADA Ken'ichi 437b1a1750 Eliminate unnecessary use of format! macro.
- Use Display::to_string in tests for conciseness.
- panic! directly takes format!-like arguments.
2019-04-09 23:11:05 +09:00
KAMADA Ken'ichi 2ffa449d9d Support displaying a value with its unit.
- Field::display_value and DisplayValue::with_unit were introduced.
- The string "centimeter" was changed to "cm" for consistency
  with "m", "mm", and "km".
- F-number was changed to be prefixed by "f/" only when with_unit() is
  called, though it is actually not a unit.
2019-04-07 21:11:14 +09:00
KAMADA Ken'ichi eb4723a8a9 Migrate to Rust 2018. 2019-04-01 21:11:54 +09:00
KAMADA Ken'ichi 56106534cd Remove the deprecated tag module. 2019-03-31 23:50:04 +09:00
kpcyrd 288a7e85c5 Remove some usage of unsafe rust 2019-03-17 23:55:10 +09:00
KAMADA Ken'ichi bbca6ea229 Use {f32,f64}::{from_bits,to_bits} instead of unsafe transmute.
These APIs were stabilized in Rust 1.20.0.
2018-04-20 22:16:21 +09:00
KAMADA Ken'ichi d882dce9a0 Update documentation and doc-tests. 2018-01-13 23:33:45 +09:00
KAMADA Ken'ichi 26a64361b3 Add `Tag::TagName`s and deprecate `tag::TagName`s. 2017-10-12 22:55:56 +09:00
KAMADA Ken'ichi 078bfcdc78 Add the 2nd member to Value::Undefined to keep the offset of the value. 2017-08-04 21:15:19 +09:00
KAMADA Ken'ichi f0a9297579 Add Value::iter_uint(). 2017-07-11 23:33:14 +09:00
KAMADA Ken'ichi 5a540228c3 Implement the body of Value::display_as(). 2017-06-17 21:57:38 +09:00
KAMADA Ken'ichi 7c61ddf3f9 Add Value::get_uint() to handle BYTE, SHORT, and LONG transparently. 2017-06-17 21:47:27 +09:00
KAMADA Ken'ichi 065276d5a1 Add converters from Rational/SRational to f64/f32.
- Rational::to_f64() and SRational::to_f64().
- From<Rational> and From<SRational> traits for f64 and f32.
2017-06-14 23:28:20 +09:00
KAMADA Ken'ichi 94e62181eb Derive Copy and Clone traits for Rational and SRational. 2017-06-14 23:23:53 +09:00
KAMADA Ken'ichi 0d9551af0f Add a struct for displaying a value in a tag-specific way. 2017-05-11 23:19:16 +09:00
KAMADA Ken'ichi 91ce94844c Implement std::fmt::Display for Rational and SRational. 2017-04-08 20:21:54 +09:00
KAMADA Ken'ichi 81b5efa7aa Cleanup imports and require Rust 1.15. 2017-03-24 23:09:22 +09:00
KAMADA Ken'ichi 7f66863d84 Add Tag.default_value(). 2017-03-24 22:46:26 +09:00
KAMADA Ken'ichi 61d78aa197 Test parsing an unknown field. 2017-03-14 21:53:48 +09:00
KAMADA Ken'ichi b66b47d1fd More tests on out-of-range accesses around unsafe code. 2017-03-12 19:16:00 +09:00
KAMADA Ken'ichi 4f2e54a6b9 Parse an empty ASCII field into an empty Vec.
The previous behavior was chosen to ensure that value[0] is always
present, but it is inconsistent with that of other fields.
2017-03-12 19:13:21 +09:00
KAMADA Ken'ichi 2a0c4d9f61 Fix comments on Value variants. 2016-12-30 23:19:02 +09:00
KAMADA Ken'ichi eaaad2418f Parse DOUBLE fields. 2016-11-19 20:46:49 +09:00
KAMADA Ken'ichi 60b6455905 Parse FLOAT fields. 2016-11-19 20:43:41 +09:00
KAMADA Ken'ichi 2bb71cfefb Parse SRATIONAL fields. 2016-11-19 20:28:17 +09:00
KAMADA Ken'ichi 0741492615 Parse SLONG fields. 2016-11-19 20:21:08 +09:00
KAMADA Ken'ichi 4acfa58e44 Parse SSHORT fields. 2016-11-19 20:16:49 +09:00
KAMADA Ken'ichi 2612b22d54 Parse UNDEFINED fields. 2016-11-19 20:10:12 +09:00
KAMADA Ken'ichi 471f9394c4 Parse SBYTE fields. 2016-11-17 21:32:17 +09:00
KAMADA Ken'ichi 3788c45482 Parse RATIONAL fields. 2016-11-17 21:14:07 +09:00
KAMADA Ken'ichi e84675d5a7 Parse LONG fields. 2016-11-17 21:03:34 +09:00
KAMADA Ken'ichi 111a2fd34c Test unitlen more. 2016-11-16 23:16:53 +09:00
KAMADA Ken'ichi a8620a1ff6 Pre-allocate a Vec since the count of a TIFF field value is known. 2016-11-16 23:13:29 +09:00
KAMADA Ken'ichi 6225236870 Adjust parse_ascii() tester to match with others. 2016-11-04 22:11:57 +09:00
KAMADA Ken'ichi b86c74856c Test parse_short(). 2016-11-03 19:52:18 +09:00
KAMADA Ken'ichi 8bff68fccc Implement and test parse_byte(). 2016-11-03 19:49:10 +09:00
KAMADA Ken'ichi 6f9be2c2a9 Return a usize for the unit length from get_type_info(). 2016-11-03 18:51:54 +09:00
KAMADA Ken'ichi f99eae06ca Test parse_ascii(). 2016-10-27 20:53:07 +09:00
KAMADA Ken'ichi 3df4f323d7 An ASCII field may contain multiple strings. 2016-10-27 20:48:38 +09:00
KAMADA Ken'ichi 0e9512472c Parse TIFF IFD structure. 2016-10-26 22:46:20 +09:00