| 1 | #[repr(C)] |
| 2 | #[cfg_attr(feature = "serde", derive(serderust-analyzer cargo serde 1.0.225 crate/::Serializerust-analyzer cargo serde_derive 1.0.225 Serialize:, serderust-analyzer cargo serde 1.0.225 crate/::Deserializerust-analyzer cargo serde_derive 1.0.225 Deserialize:))] |
| 3 | #[cfg_attr(feature = "defmt-03", derive(defmtrust-analyzer cargo defmt 0.3.100 crate/::Formatrust-analyzer cargo defmt-macros 1.0.1 Format:))] |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 5 | /// A `Grayscale` pixel (rgb crate v0.8) |
| 6 | #[allow(non_camel_case_types)] |
| 7 | pub struct Gray_v08rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#<T>( |
| 8 | /// Grayscale Component. This field will be renamed to `v`. |
| 9 | #[deprecated(note = "Please use .value() or .value_mut() instead. This field will be renamed to .v in the next major version")] |
| 10 | pub T, |
| 11 | ); |
| 12 | |
| 13 | impl<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> Gray_v08rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#<T> { |
| 14 | /// Reads the `.0` field |
| 15 | /// |
| 16 | /// This function isn't necessary, but it is forwards-compatible with the next major version of the RGB crate. |
| 17 | #[allow(deprecated)] |
| 18 | pub fn valuerust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v08<T>`]value().(self) -> T { |
| 19 | self.0rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#0. |
| 20 | } |
| 21 | |
| 22 | /// Exposes the `.0` field for writing |
| 23 | /// |
| 24 | /// This function isn't necessary, but it is forwards-compatible with the next major version of the RGB crate. |
| 25 | #[allow(deprecated)] |
| 26 | pub fn value_mutrust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v08<T>`]value_mut().(&mut self) -> &mut T { |
| 27 | &mut self.0rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#0. |
| 28 | } |
| 29 | |
| 30 | /// Add alpha component to this pixel |
| 31 | #[allow(deprecated)] |
| 32 | pub fn with_alpharust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v08<T>`]with_alpha().(self, add_alpha_value: T) -> craterust-analyzer cargo rgb 0.8.53 crate/::formatsrust-analyzer cargo rgb 0.8.53 formats/::gray_alpharust-analyzer cargo rgb 0.8.53 formats/gray_alpha/::GrayAlpha_v08rust-analyzer cargo rgb 0.8.53 formats/gray_alpha/GrayAlpha_v08#<T> { |
| 33 | craterust-analyzer cargo rgb 0.8.53 crate/::formatsrust-analyzer cargo rgb 0.8.53 formats/::gray_alpharust-analyzer cargo rgb 0.8.53 formats/gray_alpha/::GrayAlpha_v08rust-analyzer cargo rgb 0.8.53 formats/gray_alpha/GrayAlpha_v08#(self.0rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#0., add_alpha_value) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | #[cfg(feature = "unstable-experimental")] |
| 38 | /// A `Grayscale` pixel (rgb crate v0.9) |
| 39 | /// |
| 40 | /// This is the new gray pixel type as opposed to the legacy gray type |
| 41 | /// (`rgb::Gray`) which is kept for backwards-compatibility. |
| 42 | /// |
| 43 | /// # Examples |
| 44 | /// |
| 45 | /// ``` |
| 46 | /// use rgb::Gray; |
| 47 | /// |
| 48 | /// let pixel: Gray<u8> = Gray { v: 0 }; |
| 49 | /// ``` |
| 50 | #[allow(non_camel_case_types)] |
| 51 | #[repr(C)] |
| 52 | #[cfg_attr(feature = "serde", derive(serderust-analyzer cargo serde 1.0.225 crate/::Serializerust-analyzer cargo serde_derive 1.0.225 Serialize:, serderust-analyzer cargo serde 1.0.225 crate/::Deserializerust-analyzer cargo serde_derive 1.0.225 Deserialize:))] |
| 53 | #[cfg_attr(feature = "defmt-03", derive(defmtrust-analyzer cargo defmt 0.3.100 crate/::Formatrust-analyzer cargo defmt-macros 1.0.1 Format:))] |
| 54 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 55 | #[doc(alias = "Luma")] |
| 56 | pub struct Gray_v09rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#<T> { |
| 57 | /// Grayscale Component |
| 58 | pub vrust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#v.: T, |
| 59 | } |
| 60 | |
| 61 | #[cfg(feature = "unstable-experimental")] |
| 62 | impl<T> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Gray_v08rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#<T> { |
| 63 | type Targetrust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v08<T>`][Deref]Target# = Gray_v09rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#<T>; |
| 64 | |
| 65 | fn derefrust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v08<T>`][Deref]deref().(&self) -> &Gray_v09rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#<T> { |
| 66 | unsafe { |
| 67 | &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *const Selfrust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v08<T>`][Deref] as *const Gray_v09rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#::<T>) |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | #[cfg(feature = "unstable-experimental")] |
| 73 | impl<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> Gray_v09rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#<T> { |
| 74 | /// Reads the `.v` field |
| 75 | /// |
| 76 | /// This function isn't necessary, but it is forwards-compatible with the next major version of the RGB crate. |
| 77 | pub fn valuerust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v09<T>`]value().(self) -> T { |
| 78 | self.vrust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#v. |
| 79 | } |
| 80 | |
| 81 | /// Exposes the `.v` field for writing |
| 82 | /// |
| 83 | /// This function isn't necessary, but it is forwards-compatible with the next major version of the RGB crate. |
| 84 | pub fn value_mutrust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v09<T>`]value_mut().(&mut self) -> &mut T { |
| 85 | &mut self.vrust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#v. |
| 86 | } |
| 87 | |
| 88 | /// Add alpha component to this pixel |
| 89 | pub fn with_alpharust-analyzer cargo rgb 0.8.53 formats/gray/impl#[`Gray_v09<T>`]with_alpha().(self, add_alpha_value: T) -> craterust-analyzer cargo rgb 0.8.53 crate/::formatsrust-analyzer cargo rgb 0.8.53 formats/::gray_arust-analyzer cargo rgb 0.8.53 formats/gray_a/::GrayArust-analyzer cargo rgb 0.8.53 formats/gray_a/GrayA#<T> { |
| 90 | craterust-analyzer cargo rgb 0.8.53 crate/::formatsrust-analyzer cargo rgb 0.8.53 formats/::gray_arust-analyzer cargo rgb 0.8.53 formats/gray_a/::GrayArust-analyzer cargo rgb 0.8.53 formats/gray_a/GrayA# { vrust-analyzer cargo rgb 0.8.53 formats/gray_a/GrayA#v.: self.vrust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#v., arust-analyzer cargo rgb 0.8.53 formats/gray_a/GrayA#a.: add_alpha_value } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 95 | #[cfg(feature = "unstable-experimental")] |
| 96 | #[allow(deprecated)] |
| 97 | fn swizzlerust-analyzer cargo rgb 0.8.53 formats/gray/swizzle().() { |
| 98 | let g = Gray_v08rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#(10u8); |
| 99 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(10, g.vrust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v09#v.); |
| 100 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(10, g.0rust-analyzer cargo rgb 0.8.53 formats/gray/Gray_v08#0.); |
| 101 | } |