diff --git a/README.md b/README.md index 9b5ba51..13e0f10 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ Add this to your `Cargo.toml`: xmp_toolkit = "0.3.8" ``` +## Breaking changes in 0.x series + +### Upgrading to 0.4 from earlier releases + +The `xmp_const` module has been removed and a new `xmp_ns` module has been added, containing constants for many common XMP namespaces. Replace `xmp_const::XMP_NS_XMP` with `xmp_ns::XMP`. + ## License The `xmp_toolkit` crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0). diff --git a/src/lib.rs b/src/lib.rs index a869a64..4f0670b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,17 +16,11 @@ #![doc = include_str!("../README.md")] mod ffi; - -mod xmp_const; -pub use xmp_const::*; - mod xmp_date_time; -pub use xmp_date_time::XmpDateTime; - mod xmp_file; -pub use xmp_file::OpenFileOptions; -pub use xmp_file::XmpFile; -pub use xmp_file::XmpFileError; - mod xmp_meta; +pub mod xmp_ns; + +pub use xmp_date_time::XmpDateTime; +pub use xmp_file::{OpenFileOptions, XmpFile, XmpFileError}; pub use xmp_meta::XmpMeta; diff --git a/src/xmp_const.rs b/src/xmp_const.rs deleted file mode 100644 index 6013a5d..0000000 --- a/src/xmp_const.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 Adobe. All rights reserved. -// This file is licensed to you under the Apache License, -// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) -// or the MIT license (http://opensource.org/licenses/MIT), -// at your option. - -// Unless required by applicable law or agreed to in writing, -// this software is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or -// implied. See the LICENSE-MIT and LICENSE-APACHE files for the -// specific language governing permissions and limitations under -// each license. - -/// The XML namespace for the XMP "basic" schema. -pub const XMP_NS_XMP: &str = "http://ns.adobe.com/xap/1.0/"; diff --git a/src/xmp_file.rs b/src/xmp_file.rs index b88e81a..aa5ead4 100644 --- a/src/xmp_file.rs +++ b/src/xmp_file.rs @@ -232,7 +232,7 @@ mod tests { use tempfile::tempdir; - use crate::{xmp_const::*, XmpDateTime}; + use crate::{xmp_ns, XmpDateTime}; fn fixture_path(name: &str) -> String { let root_dir = &env::var("CARGO_MANIFEST_DIR").unwrap(); @@ -278,9 +278,9 @@ mod tests { assert!(m.does_property_exist("http://purl.org/dc/terms/", "provenance"),); assert!(!m.does_property_exist("http://purl.org/dc/terms/", "provenancx"),); - if m.does_property_exist(XMP_NS_XMP, "MetadataDate") { + if m.does_property_exist(xmp_ns::XMP, "MetadataDate") { let updated_time = XmpDateTime::current(); - m.set_property_date(XMP_NS_XMP, "MetadataDate", &updated_time); + m.set_property_date(xmp_ns::XMP, "MetadataDate", &updated_time); } assert!(f.can_put_xmp(&m)); diff --git a/src/xmp_ns.rs b/src/xmp_ns.rs new file mode 100644 index 0000000..f1b2af0 --- /dev/null +++ b/src/xmp_ns.rs @@ -0,0 +1,78 @@ +// Copyright 2022 Adobe. All rights reserved. +// This file is licensed to you under the Apache License, +// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) +// or the MIT license (http://opensource.org/licenses/MIT), +// at your option. + +// Unless required by applicable law or agreed to in writing, +// this software is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or +// implied. See the LICENSE-MIT and LICENSE-APACHE files for the +// specific language governing permissions and limitations under +// each license. + +//! Standard XML namespace constants. + +/// The XML namespace for the XMP "basic" schema. +pub const XMP: &str = "http://ns.adobe.com/xap/1.0/"; + +/// The XML namespace for the XMP copyright schema. +pub const XMP_RIGHTS: &str = "http://ns.adobe.com/xap/1.0/rights/"; + +/// The XML namespace for the XMP digital asset management schema. +pub const XMP_MM: &str = "http://ns.adobe.com/xap/1.0/mm/"; + +/// The XML namespace for the job management schema. +pub const XMP_BJ: &str = "http://ns.adobe.com/xap/1.0/bj/"; + +/// The XML namespace for the PDF schema. +pub const PDF: &str = "http://ns.adobe.com/pdf/1.3/"; + +/// The XML namespace for the Photoshop custom schema. +pub const PHOTOSHOP: &str = "http://ns.adobe.com/photoshop/1.0/"; + +/// The XML namespace for Adobe's EXIF schema. +pub const EXIF: &str = "http://ns.adobe.com/exif/1.0/"; + +/// The XML namespace for Adobe's TIFF schema. +pub const TIFF: &str = "http://ns.adobe.com/tiff/1.0/"; + +// --- XML namespace constants for qualifiers and structured property fields --- + +/// The XML namespace for qualifiers of the `xmp:Identifier` property. +pub const IDENTIFIER_QUAL: &str = "http://ns.adobe.com/xmp/Identifier/qual/1.0/"; + +/// The XML namespace for fields of the `Dimensions` type. +pub const DIMENSIONS: &str = "http://ns.adobe.com/xap/1.0/sType/Dimensions#"; + +/// The XML namespace for fields of a graphical image. Used for the `Thumbnail` type. +pub const IMAGE: &str = "http://ns.adobe.com/xap/1.0/g/img/"; + +/// The XML namespace for fields of the `ResourceEvent` type. +pub const RESOURCE_EVENT: &str = "http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"; + +/// The XML namespace for fields of the `ResourceRef` type. +pub const RESOURCE_REF: &str = "http://ns.adobe.com/xap/1.0/sType/ResourceRef#"; + +/// The XML namespace for fields of the `Version` type. +pub const ST_VERSION: &str = "http://ns.adobe.com/xap/1.0/sType/Version#"; + +/// The XML namespace for fields of the `JobRef` type. +pub const ST_JOB: &str = "http://ns.adobe.com/xap/1.0/sType/Job#"; + +// --- XML namespace constants from outside Adobe --- + +/// The XML namespace for the Dublin Core schema. +pub const DC: &str = "http://purl.org/dc/elements/1.1/"; + +/// The XML namespace for the IPTC Core schema. +pub const IPTC_CORE: &str = "http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"; + +/// The XML namespace for the IPTC Extension schema. +pub const IPTC_EXT: &str = "http://iptc.org/std/Iptc4xmpExt/2008-02-29/"; + +/// The XML namespace for RDF. +pub const RDF: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; + +/// The XML namespace for XML. +pub const XML: &str = "http://www.w3.org/XML/1998/namespace";