crnlib

Struct Header

Source
pub struct Header {
Show 20 fields pub magic: [u8; 2], pub header_size: u16, pub header_crc16: u16, pub file_size: u32, pub data_crc16: u16, pub width: u16, pub height: u16, pub level_count: u8, pub face_count: u8, pub format: Format, pub flags: u16, pub reserved: u32, pub userdata: [u32; 2], pub color_endpoints: Palette, pub color_selectors: Palette, pub alpha_endpoints: Palette, pub alpha_selectors: Palette, pub table_size: u16, pub table_offset: u32, pub level_offset: Vec<u32>,
}

Fields§

§magic: [u8; 2]§header_size: u16§header_crc16: u16§file_size: u32§data_crc16: u16§width: u16§height: u16§level_count: u8§face_count: u8§format: Format§flags: u16§reserved: u32§userdata: [u32; 2]§color_endpoints: Palette§color_selectors: Palette§alpha_endpoints: Palette§alpha_selectors: Palette§table_size: u16§table_offset: u32§level_offset: Vec<u32>

Implementations§

Source§

impl Header

Source

pub fn parse(input: &[u8]) -> Result<Self, Error>

Source

pub fn fixed_size() -> usize

Source

pub fn crc16(init: u16, input: &[u8]) -> u16

Source

pub fn crc16_poly(init: u16, poly: u16, input: &[u8]) -> u16

Source

pub fn check_crc(&self, input: &[u8]) -> bool

Source

pub fn block_size(&self) -> usize

Source

pub fn get_level_data<'a>( &self, input: &'a [u8], idx: usize, ) -> Option<&'a [u8]>

Source

pub fn get_table(&self, input: &[u8]) -> Result<Tables, Error>

Source

pub fn get_color_endpoints( &self, input: &[u8], ) -> Result<Vec<(u16, u16)>, Error>

Source

pub fn get_alpha_endpoints(&self, input: &[u8]) -> Result<Vec<(u8, u8)>, Error>

Source

pub fn get_color_selectors(&self, input: &[u8]) -> Result<Vec<[u8; 4]>, Error>

Source

pub fn get_alpha_selectors(&self, input: &[u8]) -> Result<Vec<[u8; 6]>, Error>

Source

pub fn get_level_info(&self, idx: usize) -> Option<(u16, u16)>

Source

pub fn unpack_level( &self, tables: &Tables, input: &[u8], idx: usize, ) -> Result<Vec<u8>, Error>

Trait Implementations§

Source§

impl Debug for Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Header

Source§

fn default() -> Header

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Header

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Header

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,