Skip to content

Commit

Permalink
Add default implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Systemcluster committed Aug 24, 2024
1 parent 57a9c73 commit 4690bb8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,12 +1111,21 @@ impl ResourceTable {
}

/// Raw resource data.
#[derive(Debug, Clone, Eq, PartialEq, Default)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ResourceData {
data: DebugIgnore<Vec<u8>>,
codepage: u32,
reserved: u32,
}
impl Default for ResourceData {
fn default() -> Self {
Self {
data: Vec::new().into(),
codepage: CODE_PAGE_ID_EN_US as u32,
reserved: 0,
}
}
}
impl ResourceData {
/// Returns the raw data.
pub fn data(&self) -> &[u8] { &self.data }
Expand All @@ -1138,6 +1147,9 @@ pub enum ResourceEntry {
Table(ResourceTable),
Data(ResourceData),
}
impl Default for ResourceEntry {
fn default() -> Self { Self::Data(ResourceData::default()) }
}
impl ResourceEntry {
/// Returns if the data is a table.
pub fn is_table(&self) -> bool {
Expand Down Expand Up @@ -1234,6 +1246,9 @@ pub enum ResourceEntryName {
// 2 byte size + data
Name(Vec<u8>),
}
impl Default for ResourceEntryName {
fn default() -> Self { Self::ID(LANGUAGE_ID_EN_US as u32) }
}
impl ResourceEntryName {
fn parse(image: &[u8], offset: u32, id: u32) -> Result<Self, ReadError> {
if id & 0x80000000 != 0 {
Expand Down Expand Up @@ -1299,7 +1314,7 @@ impl ResourceEntryName {

/// Version string table.
/// This is an entry in the version info resource.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq, Default)]
pub struct VersionStringTable {
pub key: String,
pub strings: IndexMap<String, String, RandomState>,
Expand Down

0 comments on commit 4690bb8

Please sign in to comment.