Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bits and bobs for #18 #19

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading