Do not re-export Content and Tag by hiding the real tag module.

This commit is contained in:
KAMADA Ken'ichi 2017-03-12 19:18:00 +09:00
parent b66b47d1fd
commit e939ef7fd6
3 changed files with 28 additions and 19 deletions

View File

@ -48,7 +48,8 @@ pub use error::Error;
pub use image::parse_image;
pub use jpeg::get_exif_attr as get_exif_attr_from_jpeg;
pub use reader::Reader;
pub use tag::{Context, Tag};
pub use tag_priv::{Context, Tag};
pub use tag_priv::constants as tag;
pub use tiff::Field;
pub use tiff::parse_exif;
pub use value::Value;
@ -63,7 +64,8 @@ mod error;
mod image;
mod jpeg;
mod reader;
pub mod tag;
#[path = "tag.rs"]
mod tag_priv;
mod tiff;
mod util;
mod value;

View File

@ -24,16 +24,9 @@
// SUCH DAMAGE.
//
//! Compatibility warning: Exif tag constants in this module will be
//! converted to associated constants of Tag when the feature is
//! stabilized.
use std::fmt;
/// A tag of a TIFF field.
///
/// Use `exif::Tag` instead of `exif::tag::Tag`. They are the same,
/// but `exif::tag` will become private in the future versions.
//
// This is not an enum to keep safety and API stability, while
// supporting unknown tag values. This comment is based on the
@ -83,9 +76,6 @@ impl fmt::Display for Tag {
}
/// An enum that indicates how a tag value is interpreted.
///
/// Use `exif::Context` instead of `exif::tag::Context`. They are the
/// same, but `exif::tag` will become private in the future versions.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Context {
/// TIFF attributes defined in the TIFF Rev. 6.0 specification.
@ -106,11 +96,28 @@ macro_rules! generate_well_known_tag_constants {
($name:ident, $num:expr, $desc:expr)
),+, )+
) => (
$($(
$( #[$attr] )*
#[allow(non_upper_case_globals)]
pub const $name: Tag = Tag($ctx, $num);
)+)+
/// A module that contains Exif tag constants.
///
/// Compatibility warning: Exif tag constants in this module will be
/// converted to associated constants of `Tag` when the feature is
/// stabilized.
///
/// It is not recommended to import the constants directly into
/// your namespace; import the module and use with the module name
/// like `tag::DateTime`. The constant names follow the Exif
/// specification but not the Rust naming conventions, and a user
/// of the constants will get the non_upper_case_globals warning
/// if a bare constant is used in a match arm.
// This is discussed in
// <https://github.com/rust-lang/rust/issues/25207>.
pub mod constants {
use super::{Context, Tag};
$($(
$( #[$attr] )*
#[allow(non_upper_case_globals)]
pub const $name: Tag = Tag($ctx, $num);
)+)+
}
// Use a separate module to avoid name conflicts between
// const Tag and static TagInfo.
@ -130,7 +137,7 @@ macro_rules! generate_well_known_tag_constants {
fn get_tag_info(tag: &Tag) -> Option<&tag_info::TagInfo> {
match *tag {
$($(
self::$name => Some(&tag_info::$name),
constants::$name => Some(&tag_info::$name),
)+)+
_ => None,
}

View File

@ -27,7 +27,7 @@
use endian::{Endian, BigEndian, LittleEndian};
use error::Error;
use tag;
use tag::{Context, Tag};
use tag_priv::{Context, Tag};
use value::Value;
use value::get_type_info;