Skip to content

Commit

Permalink
(MINOR) New module for XMP namespace constants (#53)
Browse files Browse the repository at this point in the history
Removed `xmp_const` module in favor of `xmp_ns`, which contains constants for many common XMP namespaces.

Replace `xmp_const::XMP_NS_XMP` with `xmp_ns::XMP`.
  • Loading branch information
scouten-adobe authored Jul 6, 2022
1 parent 8bf43d1 commit 593938a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 28 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
14 changes: 4 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
15 changes: 0 additions & 15 deletions src/xmp_const.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/xmp_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down
78 changes: 78 additions & 0 deletions src/xmp_ns.rs
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit 593938a

Please sign in to comment.