outlook_mapi_macros/
lib.rs

1//! Private macros used by the [outlook-mapi](https://crates.io/crates/outlook-mapi) crate
2//! internally that are not re-exported.
3
4/// Build the common casting function `impl` block for all of the SizedXXX macros.
5#[macro_export]
6macro_rules! impl_sized_struct_casts {
7    ($name:ident, $sys_type:path) => {
8        #[allow(dead_code)]
9        impl $name {
10            pub fn as_ptr(&self) -> *const $sys_type {
11                unsafe { std::mem::transmute::<&Self, &$sys_type>(self) }
12            }
13
14            pub fn as_mut_ptr(&mut self) -> *mut $sys_type {
15                unsafe { std::mem::transmute::<&mut Self, &mut $sys_type>(self) }
16            }
17        }
18    };
19}
20
21/// Build an optional `impl Default` block for any of the SizedXXX macros.
22#[macro_export]
23macro_rules! impl_sized_struct_default {
24    ($name:ident $body:tt) => {
25        #[allow(dead_code)]
26        impl Default for $name {
27            fn default() -> Self {
28                Self $body
29            }
30        }
31    };
32}
33
34/// Get the `ulFlags` default value for any of the display table SizedXXX macros.
35#[macro_export]
36macro_rules! display_table_default_flags {
37    (u8, $unicode:expr) => {
38        0
39    };
40    (u16, $unicode:expr) => {
41        $unicode
42    };
43}