| 1 | use craterust-analyzer cargo tiff 0.11.3 crate/::encoderrust-analyzer cargo tiff 0.11.3 encoder/::TiffValuerust-analyzer cargo tiff 0.11.3 encoder/tiff_value/TiffValue#; |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/; |
| 3 | |
| 4 | macro_rules! tagsrust-analyzer cargo tiff 0.11.3 tags/tags! { |
| 5 | { |
| 6 | // Permit arbitrary meta items, which include documentation. |
| 7 | $( #[$enum_attr:meta] )* |
| 8 | $vis:vis enum $name:ident($ty:tt) $(unknown(#[$unknown_meta:meta] $unknown_doc:ident))* { |
| 9 | // Each of the `Name = Val,` permitting documentation. |
| 10 | $($(#[$ident_attr:meta])* $tag:ident = $val:expr,)* |
| 11 | } |
| 12 | } => { |
| 13 | $( #[$enum_attr] )* |
| 14 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] |
| 15 | #[non_exhaustive] |
| 16 | #[repr($ty)] |
| 17 | pub enum $name { |
| 18 | $($(#[$ident_attr])* $tag = $val,)* |
| 19 | $( |
| 20 | #[$unknown_meta] |
| 21 | Unknown($ty), |
| 22 | )* |
| 23 | } |
| 24 | |
| 25 | impl $name { |
| 26 | #[inline(always)] |
| 27 | const fn __from_inner_type(n: $ty) -> Result<Self, $ty> { |
| 28 | match n { |
| 29 | $( $val => Ok($name::$tag), )* |
| 30 | n => Err(n), |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | #[inline(always)] |
| 35 | const fn __to_inner_type(&self) -> $ty { |
| 36 | match *self { |
| 37 | $( $name::$tag => $val, )* |
| 38 | $( $name::Unknown($unknown_doc) => { $unknown_doc }, )* |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | tags!($name, $ty, $($unknown_doc)*); |
| 44 | }; |
| 45 | // For u16 tags, provide direct inherent primitive conversion methods. |
| 46 | ($name:tt, u16, $($unknown_doc:ident)*) => { |
| 47 | impl $name { |
| 48 | #[inline(always)] |
| 49 | pub const fn from_u16(val: u16) -> Option<Self> { |
| 50 | match Self::__from_inner_type(val) { |
| 51 | Ok(v) => Some(v), |
| 52 | Err(_) => None, |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | $( |
| 57 | #[inline(always)] |
| 58 | pub const fn from_u16_exhaustive($unknown_doc: u16) -> Self { |
| 59 | match Self::__from_inner_type($unknown_doc) { |
| 60 | Ok(v) => v, |
| 61 | Err(_) => $name::Unknown($unknown_doc), |
| 62 | } |
| 63 | } |
| 64 | )* |
| 65 | |
| 66 | #[inline(always)] |
| 67 | pub const fn to_u16(&self) -> u16 { |
| 68 | Self::__to_inner_type(self) |
| 69 | } |
| 70 | } |
| 71 | }; |
| 72 | // For other tag types, do nothing for now. With concat_idents one could |
| 73 | // provide inherent conversion methods for all types. |
| 74 | ($name:tt, $ty:tt, $($unknown_doc:literal)*) => {}; |
| 75 | } |
| 76 | |
| 77 | // Note: These tags appear in the order they are mentioned in the TIFF reference |
| 78 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 79 | /// TIFF tags |
| 80 | pub enum Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#(u16) unknown( |
| 81 | /// A private or extension tag |
| 82 | unknown |
| 83 | ) { |
| 84 | // Baseline tags: |
| 85 | Artistrust-analyzer cargo tiff 0.11.3 tags/Tag#Artist# = 315, |
| 86 | // grayscale images PhotometricInterpretation 1 or 3 |
| 87 | BitsPerSamplerust-analyzer cargo tiff 0.11.3 tags/Tag#BitsPerSample# = 258, |
| 88 | CellLengthrust-analyzer cargo tiff 0.11.3 tags/Tag#CellLength# = 265, // TODO add support |
| 89 | CellWidthrust-analyzer cargo tiff 0.11.3 tags/Tag#CellWidth# = 264, // TODO add support |
| 90 | // palette-color images (PhotometricInterpretation 3) |
| 91 | ColorMaprust-analyzer cargo tiff 0.11.3 tags/Tag#ColorMap# = 320, // TODO add support |
| 92 | Compressionrust-analyzer cargo tiff 0.11.3 tags/Tag#Compression# = 259, // TODO add support for 2 and 32773 |
| 93 | DateTimerust-analyzer cargo tiff 0.11.3 tags/Tag#DateTime# = 306, |
| 94 | ExtraSamplesrust-analyzer cargo tiff 0.11.3 tags/Tag#ExtraSamples# = 338, // TODO add support |
| 95 | FillOrderrust-analyzer cargo tiff 0.11.3 tags/Tag#FillOrder# = 266, // TODO add support |
| 96 | FreeByteCountsrust-analyzer cargo tiff 0.11.3 tags/Tag#FreeByteCounts# = 289, // TODO add support |
| 97 | FreeOffsetsrust-analyzer cargo tiff 0.11.3 tags/Tag#FreeOffsets# = 288, // TODO add support |
| 98 | GrayResponseCurverust-analyzer cargo tiff 0.11.3 tags/Tag#GrayResponseCurve# = 291, // TODO add support |
| 99 | GrayResponseUnitrust-analyzer cargo tiff 0.11.3 tags/Tag#GrayResponseUnit# = 290, // TODO add support |
| 100 | HostComputerrust-analyzer cargo tiff 0.11.3 tags/Tag#HostComputer# = 316, |
| 101 | ImageDescriptionrust-analyzer cargo tiff 0.11.3 tags/Tag#ImageDescription# = 270, |
| 102 | ImageLengthrust-analyzer cargo tiff 0.11.3 tags/Tag#ImageLength# = 257, |
| 103 | ImageWidthrust-analyzer cargo tiff 0.11.3 tags/Tag#ImageWidth# = 256, |
| 104 | Makerust-analyzer cargo tiff 0.11.3 tags/Tag#Make# = 271, |
| 105 | MaxSampleValuerust-analyzer cargo tiff 0.11.3 tags/Tag#MaxSampleValue# = 281, // TODO add support |
| 106 | MinSampleValuerust-analyzer cargo tiff 0.11.3 tags/Tag#MinSampleValue# = 280, // TODO add support |
| 107 | Modelrust-analyzer cargo tiff 0.11.3 tags/Tag#Model# = 272, |
| 108 | NewSubfileTyperust-analyzer cargo tiff 0.11.3 tags/Tag#NewSubfileType# = 254, // TODO add support |
| 109 | Orientationrust-analyzer cargo tiff 0.11.3 tags/Tag#Orientation# = 274, // TODO add support |
| 110 | PhotometricInterpretationrust-analyzer cargo tiff 0.11.3 tags/Tag#PhotometricInterpretation# = 262, |
| 111 | PlanarConfigurationrust-analyzer cargo tiff 0.11.3 tags/Tag#PlanarConfiguration# = 284, |
| 112 | ResolutionUnitrust-analyzer cargo tiff 0.11.3 tags/Tag#ResolutionUnit# = 296, // TODO add support |
| 113 | RowsPerStriprust-analyzer cargo tiff 0.11.3 tags/Tag#RowsPerStrip# = 278, |
| 114 | SamplesPerPixelrust-analyzer cargo tiff 0.11.3 tags/Tag#SamplesPerPixel# = 277, |
| 115 | Softwarerust-analyzer cargo tiff 0.11.3 tags/Tag#Software# = 305, |
| 116 | StripByteCountsrust-analyzer cargo tiff 0.11.3 tags/Tag#StripByteCounts# = 279, |
| 117 | StripOffsetsrust-analyzer cargo tiff 0.11.3 tags/Tag#StripOffsets# = 273, |
| 118 | SubfileTyperust-analyzer cargo tiff 0.11.3 tags/Tag#SubfileType# = 255, // TODO add support |
| 119 | Threshholdingrust-analyzer cargo tiff 0.11.3 tags/Tag#Threshholding# = 263, // TODO add support |
| 120 | XResolutionrust-analyzer cargo tiff 0.11.3 tags/Tag#XResolution# = 282, |
| 121 | YResolutionrust-analyzer cargo tiff 0.11.3 tags/Tag#YResolution# = 283, |
| 122 | // Advanced tags |
| 123 | Predictorrust-analyzer cargo tiff 0.11.3 tags/Tag#Predictor# = 317, |
| 124 | TileWidthrust-analyzer cargo tiff 0.11.3 tags/Tag#TileWidth# = 322, |
| 125 | TileLengthrust-analyzer cargo tiff 0.11.3 tags/Tag#TileLength# = 323, |
| 126 | TileOffsetsrust-analyzer cargo tiff 0.11.3 tags/Tag#TileOffsets# = 324, |
| 127 | TileByteCountsrust-analyzer cargo tiff 0.11.3 tags/Tag#TileByteCounts# = 325, |
| 128 | SubIfdrust-analyzer cargo tiff 0.11.3 tags/Tag#SubIfd# = 330, |
| 129 | // Data Sample Format |
| 130 | SampleFormatrust-analyzer cargo tiff 0.11.3 tags/Tag#SampleFormat# = 339, |
| 131 | SMinSampleValuerust-analyzer cargo tiff 0.11.3 tags/Tag#SMinSampleValue# = 340, // TODO add support |
| 132 | SMaxSampleValuerust-analyzer cargo tiff 0.11.3 tags/Tag#SMaxSampleValue# = 341, // TODO add support |
| 133 | // JPEG |
| 134 | JPEGTablesrust-analyzer cargo tiff 0.11.3 tags/Tag#JPEGTables# = 347, |
| 135 | // Subsampling |
| 136 | #[doc(alias = "YCbCrSubsampling")] |
| 137 | ChromaSubsamplingrust-analyzer cargo tiff 0.11.3 tags/Tag#ChromaSubsampling# = 530, // TODO add support |
| 138 | #[doc(alias = "YCbCrPositioning")] |
| 139 | ChromaPositioningrust-analyzer cargo tiff 0.11.3 tags/Tag#ChromaPositioning# = 531, // TODO add support |
| 140 | // GeoTIFF |
| 141 | ModelPixelScaleTagrust-analyzer cargo tiff 0.11.3 tags/Tag#ModelPixelScaleTag# = 33550, // (SoftDesk) |
| 142 | ModelTransformationTagrust-analyzer cargo tiff 0.11.3 tags/Tag#ModelTransformationTag# = 34264, // (JPL Carto Group) |
| 143 | ModelTiepointTagrust-analyzer cargo tiff 0.11.3 tags/Tag#ModelTiepointTag# = 33922, // (Intergraph) |
| 144 | // <https://web.archive.org/web/20131111073619/http://www.exif.org/Exif2-1.PDF> |
| 145 | // *Do note its typo in the Decimal id* |
| 146 | Copyrightrust-analyzer cargo tiff 0.11.3 tags/Tag#Copyright# = 33_432, |
| 147 | // <https://web.archive.org/web/20131111073619/http://www.exif.org/Exif2-1.PDF> |
| 148 | ExifDirectoryrust-analyzer cargo tiff 0.11.3 tags/Tag#ExifDirectory# = 0x8769, |
| 149 | // <https://web.archive.org/web/20131111073619/http://www.exif.org/Exif2-1.PDF> |
| 150 | GpsDirectoryrust-analyzer cargo tiff 0.11.3 tags/Tag#GpsDirectory# = 0x8825, |
| 151 | // <https://www.color.org/technotes/ICC-Technote-ProfileEmbedding.pdf> |
| 152 | IccProfilerust-analyzer cargo tiff 0.11.3 tags/Tag#IccProfile# = 34675, |
| 153 | GeoKeyDirectoryTagrust-analyzer cargo tiff 0.11.3 tags/Tag#GeoKeyDirectoryTag# = 34735, // (SPOT) |
| 154 | GeoDoubleParamsTagrust-analyzer cargo tiff 0.11.3 tags/Tag#GeoDoubleParamsTag# = 34736, // (SPOT) |
| 155 | GeoAsciiParamsTagrust-analyzer cargo tiff 0.11.3 tags/Tag#GeoAsciiParamsTag# = 34737, // (SPOT) |
| 156 | ExifVersionrust-analyzer cargo tiff 0.11.3 tags/Tag#ExifVersion# = 0x9000, |
| 157 | GdalNodatarust-analyzer cargo tiff 0.11.3 tags/Tag#GdalNodata# = 42113, // Contains areas with missing data |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /// Identifies the offset of an IFD. |
| 162 | /// |
| 163 | /// This is represented as a 64-bit integer but only BigTIFF can utilize the bits. It is encoded |
| 164 | /// as 32-bit unsigned value ([`Type::LONG`]) in regular TIFF files and as 64-bit unsigned value |
| 165 | /// ([`Type::IFD8`]) in BigTIFF files. |
| 166 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 167 | // We could be using `NonZeroU64` here but I find that this complicates semantics. This type |
| 168 | // represents the integer value stored as a value in a tag. The semantics of treating `0` as an end |
| 169 | // marker are imposed by the IFD. (It's unclear if Pointer tags such as Exif would allow `0` but in |
| 170 | // practice it just returns garbage and the validity does not matter greatly to us). |
| 171 | pub struct IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer#(pub u64); |
| 172 | |
| 173 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::LowerHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/LowerHex# for IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer# { |
| 174 | fn fmtrust-analyzer cargo tiff 0.11.3 tags/impl#[IfdPointer][LowerHex]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 175 | fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::LowerHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/LowerHex#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/num/impl#[u64][LowerHex]fmt().(&self.0rust-analyzer cargo tiff 0.11.3 tags/IfdPointer#0., f) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::UpperHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/UpperHex# for IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer# { |
| 180 | fn fmtrust-analyzer cargo tiff 0.11.3 tags/impl#[IfdPointer][UpperHex]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 181 | fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::UpperHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/UpperHex#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/num/impl#[u64][UpperHex]fmt().(&self.0rust-analyzer cargo tiff 0.11.3 tags/IfdPointer#0., f) |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 186 | /// The type of an IFD entry (a 2 byte field). |
| 187 | pub enum Typerust-analyzer cargo tiff 0.11.3 tags/Type#(u16) { |
| 188 | /// 8-bit unsigned integer |
| 189 | BYTErust-analyzer cargo tiff 0.11.3 tags/Type#BYTE# = 1, |
| 190 | /// 8-bit byte that contains a 7-bit ASCII code; the last byte must be zero |
| 191 | ASCIIrust-analyzer cargo tiff 0.11.3 tags/Type#ASCII# = 2, |
| 192 | /// 16-bit unsigned integer |
| 193 | SHORTrust-analyzer cargo tiff 0.11.3 tags/Type#SHORT# = 3, |
| 194 | /// 32-bit unsigned integer |
| 195 | LONGrust-analyzer cargo tiff 0.11.3 tags/Type#LONG# = 4, |
| 196 | /// Fraction stored as two 32-bit unsigned integers |
| 197 | RATIONALrust-analyzer cargo tiff 0.11.3 tags/Type#RATIONAL# = 5, |
| 198 | /// 8-bit signed integer |
| 199 | SBYTErust-analyzer cargo tiff 0.11.3 tags/Type#SBYTE# = 6, |
| 200 | /// 8-bit byte that may contain anything, depending on the field |
| 201 | UNDEFINEDrust-analyzer cargo tiff 0.11.3 tags/Type#UNDEFINED# = 7, |
| 202 | /// 16-bit signed integer |
| 203 | SSHORTrust-analyzer cargo tiff 0.11.3 tags/Type#SSHORT# = 8, |
| 204 | /// 32-bit signed integer |
| 205 | SLONGrust-analyzer cargo tiff 0.11.3 tags/Type#SLONG# = 9, |
| 206 | /// Fraction stored as two 32-bit signed integers |
| 207 | SRATIONALrust-analyzer cargo tiff 0.11.3 tags/Type#SRATIONAL# = 10, |
| 208 | /// 32-bit IEEE floating point |
| 209 | FLOATrust-analyzer cargo tiff 0.11.3 tags/Type#FLOAT# = 11, |
| 210 | /// 64-bit IEEE floating point |
| 211 | DOUBLErust-analyzer cargo tiff 0.11.3 tags/Type#DOUBLE# = 12, |
| 212 | /// 32-bit unsigned integer (offset) |
| 213 | IFDrust-analyzer cargo tiff 0.11.3 tags/Type#IFD# = 13, |
| 214 | /// BigTIFF 64-bit unsigned integer |
| 215 | LONG8rust-analyzer cargo tiff 0.11.3 tags/Type#LONG8# = 16, |
| 216 | /// BigTIFF 64-bit signed integer |
| 217 | SLONG8rust-analyzer cargo tiff 0.11.3 tags/Type#SLONG8# = 17, |
| 218 | /// BigTIFF 64-bit unsigned integer (offset) |
| 219 | IFD8rust-analyzer cargo tiff 0.11.3 tags/Type#IFD8# = 18, |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | impl Typerust-analyzer cargo tiff 0.11.3 tags/Type# { |
| 224 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn byte_lenrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]byte_len().(&self) -> u8 { |
| 225 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 226 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::BYTErust-analyzer cargo tiff 0.11.3 tags/Type#BYTE# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SBYTErust-analyzer cargo tiff 0.11.3 tags/Type#SBYTE# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::ASCIIrust-analyzer cargo tiff 0.11.3 tags/Type#ASCII# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::UNDEFINEDrust-analyzer cargo tiff 0.11.3 tags/Type#UNDEFINED# => 1, |
| 227 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SHORTrust-analyzer cargo tiff 0.11.3 tags/Type#SHORT# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SSHORTrust-analyzer cargo tiff 0.11.3 tags/Type#SSHORT# => 2, |
| 228 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::LONGrust-analyzer cargo tiff 0.11.3 tags/Type#LONG# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SLONGrust-analyzer cargo tiff 0.11.3 tags/Type#SLONG# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::FLOATrust-analyzer cargo tiff 0.11.3 tags/Type#FLOAT# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::IFDrust-analyzer cargo tiff 0.11.3 tags/Type#IFD# => 4, |
| 229 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::LONG8rust-analyzer cargo tiff 0.11.3 tags/Type#LONG8# |
| 230 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SLONG8rust-analyzer cargo tiff 0.11.3 tags/Type#SLONG8# |
| 231 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::DOUBLErust-analyzer cargo tiff 0.11.3 tags/Type#DOUBLE# |
| 232 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::RATIONALrust-analyzer cargo tiff 0.11.3 tags/Type#RATIONAL# |
| 233 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SRATIONALrust-analyzer cargo tiff 0.11.3 tags/Type#SRATIONAL# |
| 234 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::IFD8rust-analyzer cargo tiff 0.11.3 tags/Type#IFD8# => 8, |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn value_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]value_bytes().(&self, count: u64) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u64, craterust-analyzer cargo tiff 0.11.3 crate/::errorrust-analyzer cargo tiff 0.11.3 error/::TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#> { |
| 239 | let tag_size = u64::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u8>`]from().(self.byte_lenrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]byte_len().()); |
| 240 | |
| 241 | match count.checked_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]checked_mul().(tag_size) { |
| 242 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n), |
| 243 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(craterust-analyzer cargo tiff 0.11.3 crate/::errorrust-analyzer cargo tiff 0.11.3 error/::TiffErrorrust-analyzer cargo tiff 0.11.3 error/TiffError#::LimitsExceededrust-analyzer cargo tiff 0.11.3 error/TiffError#LimitsExceeded#), |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn endian_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]endian_bytes().(self) -> EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes# { |
| 248 | match self { |
| 249 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::BYTErust-analyzer cargo tiff 0.11.3 tags/Type#BYTE# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SBYTErust-analyzer cargo tiff 0.11.3 tags/Type#SBYTE# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::ASCIIrust-analyzer cargo tiff 0.11.3 tags/Type#ASCII# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::UNDEFINEDrust-analyzer cargo tiff 0.11.3 tags/Type#UNDEFINED# => EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Onerust-analyzer cargo tiff 0.11.3 tags/EndianBytes#One#, |
| 250 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SHORTrust-analyzer cargo tiff 0.11.3 tags/Type#SHORT# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SSHORTrust-analyzer cargo tiff 0.11.3 tags/Type#SSHORT# => EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Tworust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Two#, |
| 251 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::LONGrust-analyzer cargo tiff 0.11.3 tags/Type#LONG# |
| 252 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SLONGrust-analyzer cargo tiff 0.11.3 tags/Type#SLONG# |
| 253 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::FLOATrust-analyzer cargo tiff 0.11.3 tags/Type#FLOAT# |
| 254 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::IFDrust-analyzer cargo tiff 0.11.3 tags/Type#IFD# |
| 255 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::RATIONALrust-analyzer cargo tiff 0.11.3 tags/Type#RATIONAL# |
| 256 | | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SRATIONALrust-analyzer cargo tiff 0.11.3 tags/Type#SRATIONAL# => EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Fourrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Four#, |
| 257 | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::LONG8rust-analyzer cargo tiff 0.11.3 tags/Type#LONG8# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::SLONG8rust-analyzer cargo tiff 0.11.3 tags/Type#SLONG8# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::DOUBLErust-analyzer cargo tiff 0.11.3 tags/Type#DOUBLE# | Typerust-analyzer cargo tiff 0.11.3 tags/Type#::IFD8rust-analyzer cargo tiff 0.11.3 tags/Type#IFD8# => EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Eightrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Eight#, |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 263 | /// See [TIFF compression tags](https://www.awaresystems.be/imaging/tiff/tifftags/compression.html) |
| 264 | /// for reference. |
| 265 | pub enum CompressionMethodrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#(u16) unknown( |
| 266 | /// A custom compression method |
| 267 | unknown |
| 268 | ) { |
| 269 | Nonerust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#None# = 1, |
| 270 | Huffmanrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#Huffman# = 2, |
| 271 | Fax3rust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#Fax3# = 3, |
| 272 | Fax4rust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#Fax4# = 4, |
| 273 | LZWrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#LZW# = 5, |
| 274 | JPEGrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#JPEG# = 6, |
| 275 | // "Extended JPEG" or "new JPEG" style |
| 276 | ModernJPEGrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#ModernJPEG# = 7, |
| 277 | Deflaterust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#Deflate# = 8, |
| 278 | OldDeflaterust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#OldDeflate# = 0x80B2, |
| 279 | PackBitsrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#PackBits# = 0x8005, |
| 280 | |
| 281 | // Self-assigned by libtiff |
| 282 | ZSTDrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#ZSTD# = 0xC350, |
| 283 | |
| 284 | // Self-assigned by libtiff |
| 285 | WebPrust-analyzer cargo tiff 0.11.3 tags/CompressionMethod#WebP# = 0xC351, |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 290 | pub enum PhotometricInterpretationrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#(u16) { |
| 291 | WhiteIsZerorust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#WhiteIsZero# = 0, |
| 292 | BlackIsZerorust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#BlackIsZero# = 1, |
| 293 | RGBrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#RGB# = 2, |
| 294 | RGBPaletterust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#RGBPalette# = 3, |
| 295 | TransparencyMaskrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#TransparencyMask# = 4, |
| 296 | CMYKrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#CMYK# = 5, |
| 297 | YCbCrrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#YCbCr# = 6, |
| 298 | CIELabrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#CIELab# = 8, |
| 299 | IccLabrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#IccLab# = 9, |
| 300 | ItuLabrust-analyzer cargo tiff 0.11.3 tags/PhotometricInterpretation#ItuLab# = 10, |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 305 | pub enum PlanarConfigurationrust-analyzer cargo tiff 0.11.3 tags/PlanarConfiguration#(u16) { |
| 306 | Chunkyrust-analyzer cargo tiff 0.11.3 tags/PlanarConfiguration#Chunky# = 1, |
| 307 | Planarrust-analyzer cargo tiff 0.11.3 tags/PlanarConfiguration#Planar# = 2, |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 312 | pub enum Predictorrust-analyzer cargo tiff 0.11.3 tags/Predictor#(u16) { |
| 313 | /// No changes were made to the data |
| 314 | Nonerust-analyzer cargo tiff 0.11.3 tags/Predictor#None# = 1, |
| 315 | /// The images' rows were processed to contain the difference of each pixel from the previous one. |
| 316 | /// |
| 317 | /// This means that instead of having in order `[r1, g1. b1, r2, g2 ...]` you will find |
| 318 | /// `[r1, g1, b1, r2-r1, g2-g1, b2-b1, r3-r2, g3-g2, ...]` |
| 319 | Horizontalrust-analyzer cargo tiff 0.11.3 tags/Predictor#Horizontal# = 2, |
| 320 | /// Not currently supported |
| 321 | FloatingPointrust-analyzer cargo tiff 0.11.3 tags/Predictor#FloatingPoint# = 3, |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 326 | /// Type to represent resolution units |
| 327 | pub enum ResolutionUnitrust-analyzer cargo tiff 0.11.3 tags/ResolutionUnit#(u16) { |
| 328 | Nonerust-analyzer cargo tiff 0.11.3 tags/ResolutionUnit#None# = 1, |
| 329 | Inchrust-analyzer cargo tiff 0.11.3 tags/ResolutionUnit#Inch# = 2, |
| 330 | Centimeterrust-analyzer cargo tiff 0.11.3 tags/ResolutionUnit#Centimeter# = 3, |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 335 | pub enum SampleFormatrust-analyzer cargo tiff 0.11.3 tags/SampleFormat#(u16) unknown( |
| 336 | /// An unknown extension sample format |
| 337 | unknown |
| 338 | ) { |
| 339 | Uintrust-analyzer cargo tiff 0.11.3 tags/SampleFormat#Uint# = 1, |
| 340 | Intrust-analyzer cargo tiff 0.11.3 tags/SampleFormat#Int# = 2, |
| 341 | IEEEFPrust-analyzer cargo tiff 0.11.3 tags/SampleFormat#IEEEFP# = 3, |
| 342 | Voidrust-analyzer cargo tiff 0.11.3 tags/SampleFormat#Void# = 4, |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | tagsrust-analyzer cargo tiff 0.11.3 tags/tags!! { |
| 347 | pub enum ExtraSamplesrust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#(u16) { |
| 348 | /// There is no specified association between the sample and the image. |
| 349 | Unspecifiedrust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#Unspecified# = 0, |
| 350 | /// The sample is associated alpha, i.e. pre-multiplied color. |
| 351 | AssociatedAlpharust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#AssociatedAlpha# = 1, |
| 352 | /// The sample is unassociated alpha such as a mask. There might be more than one such sample. |
| 353 | UnassociatedAlpharust-analyzer cargo tiff 0.11.3 tags/ExtraSamples#UnassociatedAlpha# = 2, |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | /// A value represented as in-memory bytes with flexible byteorder. |
| 358 | pub struct ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer# { |
| 359 | /// The raw bytes of the value. |
| 360 | bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 361 | |
| 362 | /// The type of the value. |
| 363 | tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty.: Typerust-analyzer cargo tiff 0.11.3 tags/Type#, |
| 364 | |
| 365 | /// The number of items, as `bytes` may be oversized while holding bytes that are initialized |
| 366 | /// but not used by any value. |
| 367 | countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count.: u64, |
| 368 | |
| 369 | /// The byte order of the value. |
| 370 | byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order.: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#, |
| 371 | } |
| 372 | |
| 373 | impl ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer# { |
| 374 | /// A value with a count of zero. |
| 375 | /// |
| 376 | /// The byte order is set to the native byte order of the platform. |
| 377 | pub fn emptyrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]empty().(ty: Typerust-analyzer cargo tiff 0.11.3 tags/Type#) -> Selfrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer] { |
| 378 | ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer# { |
| 379 | bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 380 | tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty., |
| 381 | countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count.: 0, |
| 382 | byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order.: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::nativerust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]native().(), |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | /// Create a value with native byte order from in-memory data. |
| 387 | pub fn from_valuerust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]from_value().<T: TiffValuerust-analyzer cargo tiff 0.11.3 encoder/tiff_value/TiffValue#>(value: &T) -> Selfrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer] { |
| 388 | ValueBufferrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer# { |
| 389 | bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes.: value.datarust-analyzer cargo tiff 0.11.3 encoder/tiff_value/TiffValue#data().().into_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`]into_owned().(), |
| 390 | tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty.: <T as TiffValuerust-analyzer cargo tiff 0.11.3 encoder/tiff_value/TiffValue#>::FIELD_TYPErust-analyzer cargo tiff 0.11.3 encoder/tiff_value/TiffValue#FIELD_TYPE., |
| 391 | countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count.: value.countrust-analyzer cargo tiff 0.11.3 encoder/tiff_value/TiffValue#count().() as u64, |
| 392 | byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order.: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::nativerust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]native().(), |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | pub fn byte_orderrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]byte_order().(&self) -> ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder# { |
| 397 | self.byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order. |
| 398 | } |
| 399 | |
| 400 | pub fn data_typerust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]data_type().(&self) -> Typerust-analyzer cargo tiff 0.11.3 tags/Type# { |
| 401 | self.tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty. |
| 402 | } |
| 403 | |
| 404 | /// The count of items in the value. |
| 405 | pub fn countrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]count().(&self) -> u64 { |
| 406 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!({ |
| 407 | self.tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty. |
| 408 | .value_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]value_bytes().(self.countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count.) |
| 409 | .is_ok_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok_and().(|n| n <= self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as u64) |
| 410 | }); |
| 411 | |
| 412 | self.countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count. |
| 413 | } |
| 414 | |
| 415 | /// View the underlying raw bytes of this value. |
| 416 | pub fn as_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]as_bytes().(&self) -> &[u8] { |
| 417 | &self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.assumed_len_from_countrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]assumed_len_from_count().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). |
| 418 | } |
| 419 | |
| 420 | /// View the underlying mutable raw bytes of this value. |
| 421 | pub fn as_bytes_mutrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]as_bytes_mut().(&mut self) -> &mut [u8] { |
| 422 | let len = self.assumed_len_from_countrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]assumed_len_from_count().(); |
| 423 | &mut self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#len]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). |
| 424 | } |
| 425 | |
| 426 | /// Change the byte order of the value representation. |
| 427 | pub fn set_byte_orderrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]set_byte_order().(&mut self, byte_order: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#) { |
| 428 | let len = self.assumed_len_from_countrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]assumed_len_from_count().(); |
| 429 | |
| 430 | self.byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order. |
| 431 | .convertrust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]convert().(self.tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty., &mut self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#len]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()., byte_order); |
| 432 | |
| 433 | self.byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order. = byte_order; |
| 434 | } |
| 435 | |
| 436 | /// Prepare the internal for a value `to_len` bytes long. |
| 437 | /// |
| 438 | /// Shrinks the allocation if it is far too large or extends it if it is too small. In either |
| 439 | /// case ensures that at least `to_len` bytes are initialized for [`Self::raw_bytes_mut`]. |
| 440 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn prepare_lengthrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]prepare_length().(&mut self, to_len: usize) { |
| 441 | if to_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 442 | self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..resizerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize().(to_len, 0); |
| 443 | } |
| 444 | |
| 445 | if self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().to_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2 { |
| 446 | self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(to_len); |
| 447 | self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..shrink_to_fitrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]shrink_to_fit().(); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /// Internal method to change the type and count while re-interpreting the byte buffer. |
| 452 | /// |
| 453 | /// Should only be called after writing bytes to the internal buffer prepared with |
| 454 | /// `Self::prepare_length`. |
| 455 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn assume_typerust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]assume_type().(&mut self, ty: Typerust-analyzer cargo tiff 0.11.3 tags/Type#, count: u64, bo: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#) { |
| 456 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!({ |
| 457 | ty.value_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]value_bytes().(count) |
| 458 | .is_ok_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok_and().(|n| n <= self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as u64) |
| 459 | }); |
| 460 | |
| 461 | self.byte_orderrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#byte_order. = bo; |
| 462 | self.tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty. = ty; |
| 463 | self.countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count. = count; |
| 464 | } |
| 465 | |
| 466 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn raw_bytes_mutrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]raw_bytes_mut().(&mut self) -> &mut [u8] { |
| 467 | &mut self.bytesrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#bytes. |
| 468 | } |
| 469 | |
| 470 | fn assumed_len_from_countrust-analyzer cargo tiff 0.11.3 tags/impl#[ValueBuffer]assumed_len_from_count().(&self) -> usize { |
| 471 | usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(self.tyrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#ty..byte_lenrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]byte_len().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().self.countrust-analyzer cargo tiff 0.11.3 tags/ValueBuffer#count. as usize |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /// Byte order of the TIFF file. |
| 476 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 477 | pub enum ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder# { |
| 478 | /// little endian byte order |
| 479 | LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian#, |
| 480 | /// big endian byte order |
| 481 | BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian#, |
| 482 | } |
| 483 | |
| 484 | impl ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder# { |
| 485 | /// Get the byte order representing the running target. |
| 486 | /// |
| 487 | /// The infallibility of this method represents the fact that only little and big endian |
| 488 | /// systems are supported by the library. No mixed endian and no other weird stuff. (Note: as |
| 489 | /// of Rust 1.90 this is a tautology as Rust itself only has those two kinds). |
| 490 | pub const fn nativerust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]native().() -> Selfrust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder] { |
| 491 | match () { |
| 492 | #[cfg(target_endian = "little")] |
| 493 | () => ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian#, |
| 494 | #[cfg(target_endian = "big")] |
| 495 | () => ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian#, |
| 496 | #[cfg(not(any(target_endian = "big", target_endian = "little")))] |
| 497 | () => compile_errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/compile_error!!("Unsupported target"), |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | /// Given a typed buffer, convert its contents to the specified byte order in-place. |
| 502 | /// |
| 503 | /// The buffer is assumed to represent an array of the given type. If the length of the buffer |
| 504 | /// is not divisible into an integer number of values, the behavior for the remaining bytes it |
| 505 | /// not specified. |
| 506 | pub fn convertrust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]convert().(self, ty: Typerust-analyzer cargo tiff 0.11.3 tags/Type#, buffer: &mut [u8], to: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#) { |
| 507 | self.convert_endian_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]convert_endian_bytes().(ty.endian_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[Type]endian_bytes().(), buffer, to) |
| 508 | } |
| 509 | |
| 510 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn convert_endian_bytesrust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder]convert_endian_bytes().(self, cls: EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#, buffer: &mut [u8], to: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#) { |
| 511 | if self rust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder][`PartialEq<Self>`]eq().==rust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder][`PartialEq<Self>`]eq(). rust-analyzer cargo tiff 0.11.3 tags/impl#[ByteOrder][`PartialEq<Self>`]eq().to { |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | // FIXME: at MSRV 1.89 or higher use `slice::as_chunks_mut`. |
| 516 | match cls { |
| 517 | EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Onerust-analyzer cargo tiff 0.11.3 tags/EndianBytes#One# => { |
| 518 | // No change needed |
| 519 | } |
| 520 | EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Tworust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Two# => { |
| 521 | for chunk in buffer.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(2) { |
| 522 | let chunk: &mut [u8; 2] = chunk.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 523 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().chunk = u16::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_be_bytes().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().chunk).to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_le_bytes().(); |
| 524 | } |
| 525 | } |
| 526 | EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Fourrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Four# => { |
| 527 | for chunk in buffer.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(4) { |
| 528 | let chunk: &mut [u8; 4] = chunk.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 529 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().chunk = u32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_be_bytes().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().chunk).to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_le_bytes().(); |
| 530 | } |
| 531 | } |
| 532 | EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#::Eightrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Eight# => { |
| 533 | for chunk in buffer.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(8) { |
| 534 | let chunk: &mut [u8; 8] = chunk.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 535 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().chunk = u64::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_be_bytes().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().chunk).to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]to_le_bytes().(); |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | /// The size of individual byte-order corrected elements. |
| 543 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 544 | pub(craterust-analyzer cargo tiff 0.11.3 crate/) enum EndianBytesrust-analyzer cargo tiff 0.11.3 tags/EndianBytes# { |
| 545 | Onerust-analyzer cargo tiff 0.11.3 tags/EndianBytes#One#, |
| 546 | Tworust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Two#, |
| 547 | Fourrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Four#, |
| 548 | Eightrust-analyzer cargo tiff 0.11.3 tags/EndianBytes#Eight#, |
| 549 | } |