Skip to content

Commit 5e6858c

Browse files
authored
chore: move tiff tag structs to top level (#150)
* move tiff tag structs to top level * Move code out of historical `tiff` module * Rename `cog.rs` to `tiff.rs` * Rename Value to TagValue * fmt
1 parent 28d729a commit 5e6858c

File tree

19 files changed

+659
-686
lines changed

19 files changed

+659
-686
lines changed

python/src/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33

44
use async_tiff::decoder::{Decoder, DecoderRegistry};
55
use async_tiff::error::{AsyncTiffError, AsyncTiffResult};
6-
use async_tiff::tiff::tags::PhotometricInterpretation;
6+
use async_tiff::tags::PhotometricInterpretation;
77
use bytes::Bytes;
88
use pyo3::exceptions::PyTypeError;
99
use pyo3::intern;

python/src/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use async_tiff::reader::Endianness;
2-
use async_tiff::tiff::tags::{
2+
use async_tiff::tags::{
33
CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, ResolutionUnit,
44
SampleFormat,
55
};

python/src/value.rs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use async_tiff::tiff::Value;
1+
use async_tiff::TagValue;
22
use pyo3::exceptions::PyRuntimeError;
33
use pyo3::prelude::*;
44
use pyo3::IntoPyObjectExt;
55

6-
pub struct PyValue(Value);
6+
pub struct PyValue(TagValue);
77

88
impl<'py> IntoPyObject<'py> for PyValue {
99
type Target = PyAny;
@@ -12,37 +12,39 @@ impl<'py> IntoPyObject<'py> for PyValue {
1212

1313
fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {
1414
match self.0 {
15-
Value::Byte(val) => val.into_bound_py_any(py),
16-
Value::Short(val) => val.into_bound_py_any(py),
17-
Value::SignedByte(val) => val.into_bound_py_any(py),
18-
Value::SignedShort(val) => val.into_bound_py_any(py),
19-
Value::Signed(val) => val.into_bound_py_any(py),
20-
Value::SignedBig(val) => val.into_bound_py_any(py),
21-
Value::Unsigned(val) => val.into_bound_py_any(py),
22-
Value::UnsignedBig(val) => val.into_bound_py_any(py),
23-
Value::Float(val) => val.into_bound_py_any(py),
24-
Value::Double(val) => val.into_bound_py_any(py),
25-
Value::List(val) => val
15+
TagValue::Byte(val) => val.into_bound_py_any(py),
16+
TagValue::Short(val) => val.into_bound_py_any(py),
17+
TagValue::SignedByte(val) => val.into_bound_py_any(py),
18+
TagValue::SignedShort(val) => val.into_bound_py_any(py),
19+
TagValue::Signed(val) => val.into_bound_py_any(py),
20+
TagValue::SignedBig(val) => val.into_bound_py_any(py),
21+
TagValue::Unsigned(val) => val.into_bound_py_any(py),
22+
TagValue::UnsignedBig(val) => val.into_bound_py_any(py),
23+
TagValue::Float(val) => val.into_bound_py_any(py),
24+
TagValue::Double(val) => val.into_bound_py_any(py),
25+
TagValue::List(val) => val
2626
.into_iter()
2727
.map(|v| PyValue(v).into_bound_py_any(py))
2828
.collect::<PyResult<Vec<_>>>()?
2929
.into_bound_py_any(py),
30-
Value::Rational(num, denom) => (num, denom).into_bound_py_any(py),
31-
Value::RationalBig(num, denom) => (num, denom).into_bound_py_any(py),
32-
Value::SRational(num, denom) => (num, denom).into_bound_py_any(py),
33-
Value::SRationalBig(num, denom) => (num, denom).into_bound_py_any(py),
34-
Value::Ascii(val) => val.into_bound_py_any(py),
35-
Value::Ifd(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'Ifd'")),
36-
Value::IfdBig(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'IfdBig'")),
30+
TagValue::Rational(num, denom) => (num, denom).into_bound_py_any(py),
31+
TagValue::RationalBig(num, denom) => (num, denom).into_bound_py_any(py),
32+
TagValue::SRational(num, denom) => (num, denom).into_bound_py_any(py),
33+
TagValue::SRationalBig(num, denom) => (num, denom).into_bound_py_any(py),
34+
TagValue::Ascii(val) => val.into_bound_py_any(py),
35+
TagValue::Ifd(_val) => Err(PyRuntimeError::new_err("Unsupported value type 'Ifd'")),
36+
TagValue::IfdBig(_val) => {
37+
Err(PyRuntimeError::new_err("Unsupported value type 'IfdBig'"))
38+
}
3739
v => Err(PyRuntimeError::new_err(format!(
3840
"Unknown value type: {v:?}"
3941
))),
4042
}
4143
}
4244
}
4345

44-
impl From<Value> for PyValue {
45-
fn from(value: Value) -> Self {
46+
impl From<TagValue> for PyValue {
47+
fn from(value: TagValue) -> Self {
4648
Self(value)
4749
}
4850
}

src/decoder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use std::io::{Cursor, Read};
77
use bytes::Bytes;
88
use flate2::bufread::ZlibDecoder;
99

10-
use crate::error::AsyncTiffResult;
11-
use crate::tiff::tags::{CompressionMethod, PhotometricInterpretation};
12-
use crate::tiff::{TiffError, TiffUnsupportedError};
10+
use crate::error::{AsyncTiffResult, TiffError, TiffUnsupportedError};
11+
use crate::tags::{CompressionMethod, PhotometricInterpretation};
1312

1413
/// A registry of decoders.
1514
///

0 commit comments

Comments
 (0)