Skip to content

Commit

Permalink
Bits and bobs for #18 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeWaka committed Dec 24, 2023
1 parent 1a74fc8 commit 516f663
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use bitflags::bitflags;

bitflags! {
/// The possible values for a direction in DM.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Dirs: u8 {
const NORTH = 1 << 0;
const SOUTH = 1 << 1;
Expand Down
14 changes: 14 additions & 0 deletions src/icon.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::dirs::Dirs;
use crate::{error, ztxt, RawDmi};
use image::codecs::png;
use image::imageops;
Expand All @@ -8,13 +9,26 @@ use std::io::Cursor;
use std::num::NonZeroU32;

#[derive(Clone, Default, PartialEq, Debug)]
/// A DMI Icon, which is a collection of [IconState]s.
pub struct Icon {
pub version: DmiVersion,
pub width: u32,
pub height: u32,
pub states: Vec<IconState>,
}

/// The ordering of directions within a DMI file.
pub const DIR_ORDERING: [Dirs; 8] = [
Dirs::SOUTH,
Dirs::NORTH,
Dirs::EAST,
Dirs::WEST,
Dirs::SOUTHEAST,
Dirs::SOUTHWEST,
Dirs::NORTHEAST,
Dirs::NORTHWEST,
];

impl Icon {
pub fn load<R: Read>(reader: R) -> Result<Icon, error::DmiError> {
let raw_dmi = RawDmi::load(reader)?;
Expand Down

0 comments on commit 516f663

Please sign in to comment.