Share ByteOrder in tags, publicly
This commit is contained in:
1 parent
2058b7f3ca
commit
19ac30ac3f
2 files changed
+28
-8
No files matched your search
@@ -1,14 +1,7 @@
|
|||||||
//! All IO functionality needed for TIFF decoding
|
//! All IO functionality needed for TIFF decoding
|
||||||
use std::io::{self, BufRead, BufReader, Read, Seek, Take};
|
use std::io::{self, BufRead, BufReader, Read, Seek, Take};
|
||||||
|
|
||||||
/// Byte order of the TIFF file.
|
pub use crate::tags::ByteOrder;
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub enum ByteOrder {
|
|
||||||
/// little endian byte order
|
|
||||||
LittleEndian,
|
|
||||||
/// big endian byte order
|
|
||||||
BigEndian,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reader that is aware of the byte order.
|
/// Reader that is aware of the byte order.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
+27
@@ -296,3 +296,30 @@ pub enum SampleFormat(u16) unknown(
|
|||||||
Void = 4,
|
Void = 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Byte order of the TIFF file.
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
pub enum ByteOrder {
|
||||||
|
/// little endian byte order
|
||||||
|
LittleEndian,
|
||||||
|
/// big endian byte order
|
||||||
|
BigEndian,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ByteOrder {
|
||||||
|
/// Get the byte order representing the running target.
|
||||||
|
///
|
||||||
|
/// The infallibility of this method represents the fact that only little and big endian
|
||||||
|
/// systems are supported by the library. No mixed endian and no other weird stuff. (Note: as
|
||||||
|
/// of Rust 1.90 this is a tautology as Rust itself only has those two kinds).
|
||||||
|
pub const fn native() -> Self {
|
||||||
|
match () {
|
||||||
|
#[cfg(target_endian = "little")]
|
||||||
|
() => ByteOrder::LittleEndian,
|
||||||
|
#[cfg(target_endian = "big")]
|
||||||
|
() => ByteOrder::BigEndian,
|
||||||
|
#[cfg(not(any(target_endian = "big", target_endian = "little")))]
|
||||||
|
() => compile_error!("Unsupported target"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user