|
1 | | -use async_tiff::tiff::tags::{ |
2 | | - CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, ResolutionUnit, |
3 | | - SampleFormat, |
| 1 | +use async_tiff::{ |
| 2 | + reader::Endianness, |
| 3 | + tiff::tags::{ |
| 4 | + CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, |
| 5 | + ResolutionUnit, SampleFormat, |
| 6 | + }, |
4 | 7 | }; |
5 | 8 | use pyo3::prelude::*; |
6 | 9 | use pyo3::types::{PyString, PyTuple}; |
7 | 10 | use pyo3::{intern, IntoPyObjectExt}; |
8 | 11 |
|
| 12 | +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 13 | +#[pyclass(eq, eq_int, name = "Endianness")] |
| 14 | +#[repr(u16)] |
| 15 | +pub(crate) enum PyEndianness { |
| 16 | + LittleEndian = 0x4949, // b"II" |
| 17 | + BigEndian = 0x4D4D, // b"MM" |
| 18 | +} |
| 19 | + |
| 20 | +impl From<Endianness> for PyEndianness { |
| 21 | + fn from(value: Endianness) -> Self { |
| 22 | + match value { |
| 23 | + Endianness::LittleEndian => Self::LittleEndian, |
| 24 | + Endianness::BigEndian => Self::BigEndian, |
| 25 | + } |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +impl From<PyEndianness> for Endianness { |
| 30 | + fn from(value: PyEndianness) -> Self { |
| 31 | + match value { |
| 32 | + PyEndianness::LittleEndian => Self::LittleEndian, |
| 33 | + PyEndianness::BigEndian => Self::BigEndian, |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | + |
9 | 38 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
10 | 39 | pub(crate) struct PyCompressionMethod(CompressionMethod); |
11 | 40 |
|
|
0 commit comments