pub fn find_free_sectors(&self) -> Vec<(u64, u64)> {
        assert!(self.align > 0, "align must be greater than 0");
        let mut positions = Vec::new();
        positions.push(self.header.first_usable_lba - 1);
        for partition in self.partitions.iter().filter(|x| x.is_used()) {
            positions.push(partition.starting_lba);
            positions.push(partition.ending_lba);
        }
        positions.push(self.header.last_usable_lba + 1);
        positions.sort_unstable();

        positions
            .chunks(2)
            .map(|x| (x[0] + 1, x[1] - x[0] - 1))
            .filter(|(_, l)| *l > 0)
            .map(|(i, l)| (i, l, ((i - 1) / self.align + 1) * self.align - i))
            .map(|(i, l, s)| (i + s, l.saturating_sub(s)))
            .filter(|(_, l)| *l > 0)
            .collect()
    }
/// Find free spots in the partition table.
/// This function will return a vector of tuple with on the left: the starting LBA of the free
/// spot; and on the right: the size (in sectors) of the free spot.
/// This function will automatically align with the alignment defined in the `GPT`.
///
/// # Examples
///
/// Basic usage:
/// ```
/// let ss = 512;
/// let data = vec![0; 100 * ss as usize];
/// let mut cur = std::io::Cursor::new(data);
/// let mut gpt = gptman::GPT::new_from(&mut cur, ss as u64, [0xff; 16])
///     .expect("could not create partition table");
///
/// gpt[1] = gptman::GPTPartitionEntry {
///     partition_type_guid: [0xff; 16],
///     unique_partition_guid: [0xff; 16],
///     starting_lba: gpt.header.first_usable_lba + 5,
///     ending_lba: gpt.header.last_usable_lba - 5,
///     attribute_bits: 0,
///     partition_name: "A Robot Named Fight!".into(),
/// };
///
/// // NOTE: align to the sectors, so we can use every last one of them
/// // NOTE: this is only for the demonstration purpose, this is not recommended
/// gpt.align = 1;
///
/// assert_eq!(
///     gpt.find_free_sectors(),
///     vec![(gpt.header.first_usable_lba, 5), (gpt.header.last_usable_lba - 4, 5)]
/// );
/// ```
Find free spots in the partition table.
This function will return a vector of tuple with on the left: the starting LBA of the free
spot; and on the right: the size (in sectors) of the free spot.
This function will automatically align with the alignment defined in the `GPT`.
Find free spots in the partition table . This function will return a vector of tuple with on the left : the starting LBA of the free spot ; and on the right : the size ( in sectors ) of the free spot . This function will automatically align with the alignment defined in the ` GPT ` .
pub fn find_free_sectors(&self) -> Vec<(u64, u64)> {
        assert!(self.align > 0, "align must be greater than 0");
        let mut positions = Vec::new();
        positions.push(self.header.first_usable_lba - 1);
        for partition in self.partitions.iter().filter(|x| x.is_used()) {
            positions.push(partition.starting_lba);
            positions.push(partition.ending_lba);
        }
        positions.push(self.header.last_usable_lba + 1);
        positions.sort_unstable();
        positions
            .chunks(2)
            .map(|x| (x[0] + 1, x[1] - x[0] - 1))
            .filter(|(_, l)| *l > 0)
            .map(|(i, l)| (i, l, ((i - 1) / self.align + 1) * self.align - i))
            .map(|(i, l, s)| (i + s, l.saturating_sub(s)))
            .filter(|(_, l)| *l > 0)
            .collect()
    }
pub fn find_free_sectors ( & self ) -> Vec < ( u64 , u64 ) > { assert ! ( self align 0 " " ) ; let mut positions = Vec :: new ( ) ; positions . push ( self . header . first_usable_lba - 1 ) ; for partition in self . partitions . iter ( ) . filter ( | x | x . is_used ( ) ) { positions . push ( partition . starting_lba ) ; positions . push ( partition . ending_lba ) ; } positions . push ( self . header . last_usable_lba + 1 ) ; positions . sort_unstable ( ) ; positions . chunks ( 2 ) . map ( | x | ( x [ 0 ] + 1 , x [ 1 ] - x [ 0 ] - 1 ) ) . filter ( | ( _ , l ) | * l > 0 ) . map ( | ( i , l ) | ( i , l , ( ( i - 1 ) / self . align + 1 ) * self . align - i ) ) . map ( | ( i , l , s ) | ( i + s , l . saturating_sub ( s ) ) ) . filter ( | ( _ , l ) | * l > 0 ) . collect ( ) }
Find free spots in the partition table.
Find free spots in the partition table .
&self
&self
examples
Basic usage:
```
let ss = 512;
let data = vec![0; 100 * ss as usize];
let mut cur = std::io::Cursor::new(data);
let mut gpt = gptman::GPT::new_from(&mut cur, ss as u64, [0xff; 16])
.expect("could not create partition table").

gpt[1] = gptman::GPTPartitionEntry {
partition_type_guid: [0xff; 16],
unique_partition_guid: [0xff; 16],
starting_lba: gpt.header.first_usable_lba + 5,
ending_lba: gpt.header.last_usable_lba - 5,
attribute_bits: 0,
partition_name: "A Robot Named Fight!".into(),
}.

align to the sectors, so we can use every last one of them
NOTE: this is only for the demonstration purpose, this is not recommended
gpt.align = 1.


Basic usage : ` ` ` let ss = 512 ; let data = vec! [ 0 ; 100 * ss as usize ] ; let mut cur = std :: io :: Cursor :: new ( data ) ; let mut gpt = gptman :: GPT :: new_from ( &mut cur ss as u64 [ 0xff ; 16 ] ) . expect ( " could not create partition table " ) . gpt [ 1 ] = gptman :: GPTPartitionEntry { partition_type_guid : [ 0xff ; 16 ] unique_partition_guid : [ 0xff ; 16 ] starting_lba : gpt . header . first_usable_lba + 5 ending_lba : gpt . header . last_usable_lba - 5 attribute_bits : 0 partition_name : " A Robot Named Fight! " . into () } . align to the sectors so we can use every last one of them NOTE : this is only for the demonstration purpose this is not recommended gpt . align = 1 .