You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: patch.rs
    path of file: ./repos/Hypervisor-101-in-Rust/hypervisor/src
    
    the code of the file until where you have to start completion: //! The module containing types and functions to apply and revert patches.

use crate::{
    disk::{open_file, read_file_to_vec},
    Page,
};
use alloc::vec::Vec;
use log::{error, info, trace};
use serde::{Deserialize, Serialize};
use uefi::proto::media::file::Directory;
use x86::current::paging::BASE_PAGE_SHIFT;

/// The collection of [`PatchEntry`]. See also README.md.
#[derive(Debug, Serialize, Deserialize)]
#[allow(clippy::unsafe_derive_deserialize)]
pub(crate) struct PatchSet {
    entries: Vec<PatchEntry>,
}

impl PatchSet {
    /// Creates [`PatchSet`] from the patch file specified by `patch_path`.
    pub(crate) fn new(dir: &mut Directory, patch_path: &str) -> Result<Self, uefi::Error> {
        let mut patch_file = open_file(dir, patch_path)?
    
    pub(crate) fn apply(&self, pfn: usize, page: &mut Page) {
        // Find `PatchEntry`s that are within the page specified by `pfn`.
        // `self.entries` is sorted so the range (low and high indexes) can be
        // efficiently searched with `partition_point`.
        let to_pfn = |address| address as usize >> BASE_PAGE_SHIFT;
        let low = self.entries.partition_point(|e| to_pfn(e.address) < pfn);
        let high = self.entries.partition_point(|e| to_pfn(e.address) <= pfn);

        // Apply found patches for this page if any.
        self.entries[low..high].iter().for_each(|entry| {
            let page_offset = (entry.address & 0xfff) as usize;
            let length = entry.length;
            let patch = entry.patch.to_le_bytes();
            page.0[page_offset..page_offset + length].copy_from_slice(&patch[..length]);
        });
        if !self.entries[low..high].is_empty() {
            trace!("Patch applied at {} locations", self.entries[low..high].len());
        }
    }