pub fn add_data(&mut self, address: u32, data: &'a [u8]) -> Result<(), FlashBuilderError> {
        // Add the operation to the sorted data list.
        match self
            .flash_operations
            .binary_search_by_key(&address, |&v| v.address)
        {
            Ok(_) => return Err(FlashBuilderError::DoubleDataEntry(address)),
            Err(position) => self
                .flash_operations
                .insert(position, FlashOperation::new(address, data)),
        }
        self.buffered_data_size += data.len();

        // Verify that the data list does not have overlapping addresses.
        let mut previous_operation: Option<&FlashOperation> = None;
        for operation in &self.flash_operations {
            if let Some(previous) = previous_operation {
                if previous.address + previous.data.len() as u32 > operation.address {
                    return Err(FlashBuilderError::DataOverlap(operation.address));
                }
            }
            previous_operation = Some(operation);
        }
        Ok(())
    }
/// Add a block of data to be programmed.
///
/// Programming does not start until the `program` method is called.
Add a block of data to be programmed.
Programming does not start until the `program` method is called.
Add a block of data to be programmed . Programming does not start until the ` program ` method is called .
pub fn add_data(&mut self, address: u32, data: &'a [u8]) -> Result<(), FlashBuilderError> {
        // Add the operation to the sorted data list.
        match self
            .flash_operations
            .binary_search_by_key(&address, |&v| v.address)
        {
            Ok(_) => return Err(FlashBuilderError::DoubleDataEntry(address)),
            Err(position) => self
                .flash_operations
                .insert(position, FlashOperation::new(address, data)),
        }
        self.buffered_data_size += data.len();
        // Verify that the data list does not have overlapping addresses.
        let mut previous_operation: Option<&FlashOperation> = None;
        for operation in &self.flash_operations {
            if let Some(previous) = previous_operation {
                if previous.address + previous.data.len() as u32 > operation.address {
                    return Err(FlashBuilderError::DataOverlap(operation.address));
                }
            }
            previous_operation = Some(operation);
        }
        Ok(())
    }
pub fn add_data ( & mut self , address : u32 , data : & ' a [ u8 ] ) -> Result < ( ) , FlashBuilderError > { // Add the operation to the sorted data list. match self . flash_operations . binary_search_by_key ( & address , | & v | v . address ) { Ok ( _ ) => return Err ( FlashBuilderError :: DoubleDataEntry ( address ) ) , Err ( position ) => self . flash_operations . insert ( position , FlashOperation :: new ( address , data ) ) , } self . buffered_data_size += data . len ( ) ; // Verify that the data list does not have overlapping addresses. let mut previous_operation : Option < & FlashOperation > = None ; for operation in & self . flash_operations { if let Some ( previous ) = previous_operation { if previous . address + previous . data . len ( ) as u32 > operation . address { return Err ( FlashBuilderError :: DataOverlap ( operation . address ) ) ; } } previous_operation = Some ( operation ) ; } Ok ( ( ) ) }
Add a block of data to be programmed.
Add a block of data to be programmed .
&mut self
address
u32
data
&'a [u8]