Skip to main content

Resource

Derive Macro Resource 

Source
#[derive(Resource)]
{
    // Attributes available to this derive:
    #[resource]
}
Expand description

Make a struct readable from a resource fork

Macintosh ’PNT ’ resource for example could be defined as:

#[derive(Debug, Copy, Clone, BinRead, Resource)]
#[resource(code = "PNT ")]
pub struct Point {
   pub x: i16,
   pub y: i16,
}

and then read from a resource fork using:

let fork = ResourceFork::open("sample").unwrap();
let point: Point = fork.read(12).unwrap();

assert_eq!(point.x, 12);
assert_eq!(point.y, 12);