use super::*;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct PLTE<'b>(&'b [[u8; 3]]);
impl<'b> From<&'b [[u8; 3]]> for PLTE<'b> {
#[inline]
#[must_use]
fn from(entries: &'b [[u8; 3]]) -> Self {
Self(entries)
}
}
impl<'b> TryFrom<PngChunk<'b>> for PLTE<'b> {
type Error = ();
#[inline]
fn try_from(value: PngChunk<'b>) -> Result<Self, Self::Error> {
match value {
PngChunk::PLTE(plte) => Ok(plte),
_ => Err(()),
}
}
}
impl Debug for PLTE<'_> {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("PLTE").field(&&self.0[..self.0.len().min(4)]).field(&self.0.len()).finish()
}
}
impl<'b> PLTE<'b> {
#[inline]
pub fn entries(&self) -> &'b [[u8; 3]] {
self.0
}
}