Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ license = "BSD-2-Clause"

[dependencies]
mutate_once = "0.1.1"
serde = { version = "~1", features = ["derive"] }
7 changes: 5 additions & 2 deletions src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

use std::fmt;

use serde::Deserialize;
use serde::Serialize;

use crate::error::Error;
use crate::value;
use crate::value::Value;
Expand Down Expand Up @@ -55,7 +58,7 @@ use crate::util::atou16;
// PartialEq and Eq need to be _automatically derived_ for Tag to
// emulate structural equivalency.
// <https://github.com/rust-lang/rfcs/pull/1445>
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct Tag(pub Context, pub u16);

impl Tag {
Expand Down Expand Up @@ -113,7 +116,7 @@ impl fmt::Display for Tag {
}

/// An enum that indicates how a tag number is interpreted.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[non_exhaustive]
pub enum Context {
/// TIFF attributes defined in the TIFF Rev. 6.0 specification.
Expand Down
6 changes: 4 additions & 2 deletions src/tiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

use std::fmt;
use mutate_once::MutOnce;
use serde::Deserialize;
use serde::Serialize;

use crate::endian::{Endian, BigEndian, LittleEndian};
use crate::error::Error;
Expand Down Expand Up @@ -99,7 +101,7 @@ impl IfdEntry {
}

/// A TIFF/Exif field.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Deserialize, PartialEq, Serialize)]
pub struct Field {
/// The tag of this field.
pub tag: Tag,
Expand All @@ -121,7 +123,7 @@ pub struct Field {
/// assert_eq!(In::PRIMARY.index(), 0);
/// assert_eq!(In::THUMBNAIL.index(), 1);
/// ```
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct In(pub u16);

impl In {
Expand Down
9 changes: 6 additions & 3 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
use std::fmt;
use std::fmt::Write as _;

use serde::Deserialize;
use serde::Serialize;

use crate::endian::Endian;
use crate::error::Error;

/// A type and values of a TIFF/Exif field.
#[derive(Clone)]
#[derive(Clone, Deserialize, PartialEq, Serialize)]
pub enum Value {
/// Vector of 8-bit unsigned integers.
Byte(Vec<u8>),
Expand Down Expand Up @@ -346,7 +349,7 @@ impl From<&DefaultValue> for Option<Value> {
}

/// An unsigned rational number, which is a pair of 32-bit unsigned integers.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Deserialize, PartialEq, Serialize)]
pub struct Rational { pub num: u32, pub denom: u32 }

impl Rational {
Expand Down Expand Up @@ -384,7 +387,7 @@ impl fmt::Display for Rational {
}

/// A signed rational number, which is a pair of 32-bit signed integers.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Deserialize, PartialEq, Serialize)]
pub struct SRational { pub num: i32, pub denom: i32 }

impl SRational {
Expand Down