lnk/extradata/
darwin_data.rs

1use binrw::BinRead;
2use encoding_rs::{Encoding, UTF_16LE};
3use getset::Getters;
4
5#[cfg(feature = "serde")]
6use serde::Serialize;
7
8use crate::strings::FixedSizeString;
9
10/// The DarwinDataBlock structure specifies an application identifier
11/// that can be used instead of a link target IDList to install an
12/// application when a shell link is activated.
13#[derive(Clone, Debug, BinRead, Getters)]
14#[cfg_attr(feature = "serde", derive(Serialize))]
15#[br(import(block_size: u32, default_codepage: &'static Encoding), pre_assert(block_size == 0x0000_00314))]
16#[getset(get = "pub")]
17#[allow(unused)]
18pub struct DarwinDataBlock {
19    /// A NULL–terminated string, defined by the system default code
20    /// page, which specifies an application identifier. This field
21    /// SHOULD be ignored.
22    #[br(args(260, default_codepage), map=|s:FixedSizeString| s.to_string())]
23    darwin_data_ansi: String,
24
25    /// An optional, NULL–terminated, Unicode string that specifies
26    /// an application identifier.
27    #[br(args(520, UTF_16LE), map=|s: FixedSizeString| if s.is_empty() {None} else {Some(s.to_string())})]
28    darwin_data_unicode: Option<String>,
29}