pub struct PageFormat {
pub header: String,
pub footer: String,
pub header_size: u64,
pub footer_size: u64,
pub file_path: String,
pub page_nubmer: u64,
}Expand description
Represents the format of a page in the output file.
This struct holds the header and footer strings for a specific file, along with their respective sizes, the path of the file, and the current page number.
Fields§
§header: String§header_size: u64§file_path: String§page_nubmer: u64Implementations§
Source§impl PageFormat
impl PageFormat
Sourcepub fn new(file_path: String, root: Option<&Path>) -> Self
pub fn new(file_path: String, root: Option<&Path>) -> Self
Constructs a new PageFormat instance for a given file path.
Initializes the header and footer for the first page of the file, calculates their sizes, and sets the initial page number to 1.
§Arguments
file_path- The path of the file for which the page format is being created.
Sourcepub fn create_page_header(file_path: &str, page_number: u64) -> String
pub fn create_page_header(file_path: &str, page_number: u64) -> String
Creates a header string for a given file path and page number.
The header includes the file name and page number.
§Arguments
file_path- The file path for which the header is being created.page_number- The current page number.
Creates a footer string for a given file path.
The footer marks the end of a code block for the file.
§Arguments
file_path- The file path for which the footer is being created.
Sourcepub fn to_relative_path(root: &Path, file_path: &Path) -> PathBuf
pub fn to_relative_path(root: &Path, file_path: &Path) -> PathBuf
Converts an absolute file path to a relative path based on the root directory. If the file path is not relative to the root, returns the original path.
Sourcepub fn get_page_header_size(&self) -> u64
pub fn get_page_header_size(&self) -> u64
Returns the size of the current page header.
Returns the size of the current page footer.
Sourcepub fn increment_page_number(&mut self)
pub fn increment_page_number(&mut self)
Increments the page number and updates the header and footer.
This method should be called when moving to the next page of the output file. It updates the page number, and recalculates the header and footer along with their sizes.