pub fn generate(&self) -> io::Result<io::Cursor<vec::Vec<u8>>> {
        let mut header_buf = io::Cursor::new(Vec::new());

        // Write all bytes to an in-memory file for the header.
        header_buf.write_all(unsafe { util::as_byte_slice(&self.hdr_base) })?;
        header_buf.write_all(unsafe { util::as_byte_slice(&self.hdr_main) })?;
        if !self.package_name.is_empty() {
            header_buf.write_all(unsafe { util::as_byte_slice(&self.hdr_pkg_name_tlv) })?;
            header_buf.write_all(self.package_name.as_ref())?;
            util::do_pad(&mut header_buf, self.package_name_pad)?;
        }

        // Put all writeable flash region header elements in.
        for wfr in &self.hdr_wfr {
            header_buf.write_all(unsafe { util::as_byte_slice(wfr) })?;
        }

        let current_length = header_buf.get_ref().len();
        util::do_pad(&mut header_buf, align4needed!(current_length))?;

        self.inject_checksum(header_buf)
    }
/// Create the header in binary form.
Create the header in binary form.
Create the header in binary form .
pub fn generate(&self) -> io::Result<io::Cursor<vec::Vec<u8>>> {
        let mut header_buf = io::Cursor::new(Vec::new());
        // Write all bytes to an in-memory file for the header.
        header_buf.write_all(unsafe { util::as_byte_slice(&self.hdr_base) })?;
        header_buf.write_all(unsafe { util::as_byte_slice(&self.hdr_main) })?;
        if !self.package_name.is_empty() {
            header_buf.write_all(unsafe { util::as_byte_slice(&self.hdr_pkg_name_tlv) })?;
            header_buf.write_all(self.package_name.as_ref())?;
            util::do_pad(&mut header_buf, self.package_name_pad)?;
        }
        // Put all writeable flash region header elements in.
        for wfr in &self.hdr_wfr {
            header_buf.write_all(unsafe { util::as_byte_slice(wfr) })?;
        }
        let current_length = header_buf.get_ref().len();
        util::do_pad(&mut header_buf, align4needed!(current_length))?;
        self.inject_checksum(header_buf)
    }
pub fn generate ( & self ) -> io :: Result < io :: Cursor < vec :: Vec < u8 > > > { let mut header_buf = io :: Cursor :: new ( Vec :: new ( ) ) ; // Write all bytes to an in-memory file for the header. header_buf . write_all ( unsafe { util :: as_byte_slice ( & self . hdr_base ) } ) ? ; header_buf . write_all ( unsafe { util :: as_byte_slice ( & self . hdr_main ) } ) ? ; if ! self . package_name . is_empty ( ) { header_buf . write_all ( unsafe { util :: as_byte_slice ( & self . hdr_pkg_name_tlv ) } ) ? ; header_buf . write_all ( self . package_name . as_ref ( ) ) ? ; util :: do_pad ( & mut header_buf , self . package_name_pad ) ? ; } // Put all writeable flash region header elements in. for wfr in & self . hdr_wfr { header_buf . write_all ( unsafe { util :: as_byte_slice ( wfr ) } ) ? ; } let current_length = header_buf . get_ref ( ) . len ( ) ; util :: do_pad ( & mut header_buf , align4needed ! ( current_length ) ) ? ; self . inject_checksum ( header_buf ) }
Create the header in binary form.
Create the header in binary form .
&self
&self