| 1 | #[cfg (all(feature = "gif" , not(target_arch = "wasm32" ), feature = "image" ))] |
| 2 | use crate::gif_support; |
| 3 | use std::marker::PhantomData; |
| 4 | #[cfg (all(not(target_arch = "wasm32" ), feature = "image" ))] |
| 5 | use std::path::Path; |
| 6 | |
| 7 | pub(super) enum Target<'a> { |
| 8 | #[cfg (all(not(target_arch = "wasm32" ), feature = "image" ))] |
| 9 | File(&'a Path), |
| 10 | Buffer(PhantomData<&'a u32>), |
| 11 | #[cfg (all(feature = "gif" , not(target_arch = "wasm32" ), feature = "image" ))] |
| 12 | Gif(Box<gif_support::GifFile>), |
| 13 | } |
| 14 | |
| 15 | pub(super) enum Buffer<'a> { |
| 16 | #[cfg (all(not(target_arch = "wasm32" ), feature = "image" ))] |
| 17 | Owned(Vec<u8>), |
| 18 | Borrowed(&'a mut [u8]), |
| 19 | } |
| 20 | |
| 21 | impl<'a> Buffer<'a> { |
| 22 | #[inline (always)] |
| 23 | pub(super) fn borrow_buffer(&mut self) -> &mut [u8] { |
| 24 | match self { |
| 25 | #[cfg (all(not(target_arch = "wasm32" ), feature = "image" ))] |
| 26 | Buffer::Owned(buf) => &mut buf[..], |
| 27 | Buffer::Borrowed(buf: &mut &mut [u8]) => buf, |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |