Major Sections
You can think of a Photoshop file as a byte slice &[u8]
.
These bytes are organized into 5 major sections, each of which have their own sub-sections.
We represent this in our code using the MajorSections
type.
# #![allow(unused_variables)] #fn main() { // Imported into the book from `src/sections/mod.rs` pub mod image_data_section; pub mod image_resources_section; pub mod layer_and_mask_information_section; /// References to the different major sections of a PSD file #[derive(Debug)] pub struct MajorSections<'a> { pub(crate) file_header: &'a [u8], pub(crate) color_mode_data: &'a [u8], pub(crate) image_resources: &'a [u8], pub(crate) layer_and_mask: &'a [u8], pub(crate) image_data: &'a [u8], } impl<'a> MajorSections<'a> { /// Given the bytes of a PSD file, return the slices that correspond to each /// of the five major sections. /// /// ┌──────────────────┐ /// │ File Header │ /// ├──────────────────┤ /// │ Color Mode Data │ /// ├──────────────────┤ /// │ Image Resources │ /// ├──────────────────┤ #}
Our parsing comes down to reading through the bytes in this byte slice and using them to create these five major sections.