pub fn write(&self, version: (u8,u8,u8), clipboard: Option<bool>) ->Vec<u8> {
        let mut data: Vec<u8> = Vec::with_capacity(8388608); //capacity of 8MB, should be sufficient
        write_version(&mut data, version);
        if clipboard.is_some() && clipboard.unwrap() && version.0 >= 4 {self.write_clipboard(&mut data, &version);}
        self.write_info(&mut data, version);
        if version.0 < 5 {write_bool(&mut data, self.triplet_feel != TripletFeel::None);}
        if version.0 >= 4 {self.write_lyrics(&mut data);}
        if version > (5,0,0) {self.write_rse_master_effect(&mut data);}
        if version.0 >= 5 {
            self.write_page_setup(&mut data);
            write_int_byte_size_string(&mut data, &self.tempo_name);
        }
        write_i32(&mut data, self.tempo.to_i32().unwrap());
        if version > (5,0,0) {write_bool(&mut data, self.hide_tempo);}
        write_i32(&mut data, self.key.key.to_i32().unwrap());

        if version.0 >= 4 {write_signed_byte(&mut data, 0);} //octave
        self.write_midi_channels(&mut data); //TODO: fixme for writing
        //return data;

        if version.0 == 5 {
            self.write_directions(&mut data);
            self.write_master_reverb(&mut data);
        }

        write_i32(&mut data, self.tracks[0].measures.len().to_i32().unwrap());
        write_i32(&mut data, self.tracks.len().to_i32().unwrap());
        self.write_measure_headers(&mut data, &version);
        self.write_tracks(&mut data, &version);
        self.write_measures(&mut data, &version);
        write_i32(&mut data, 0);
        data
    }
/// Write data to a Vec<u8>, you are free to use the encoded data to write it in a file or in a database or do something else.
Write data to a Vec, you are free to use the encoded data to write it in a file or in a database or do something else.
Write data to a Vec you are free to use the encoded data to write it in a file or in a database or do something else .
pub fn write(&self, version: (u8,u8,u8), clipboard: Option<bool>) ->Vec<u8> {
        let mut data: Vec<u8> = Vec::with_capacity(8388608); //capacity of 8MB, should be sufficient
        write_version(&mut data, version);
        if clipboard.is_some() && clipboard.unwrap() && version.0 >= 4 {self.write_clipboard(&mut data, &version);}
        self.write_info(&mut data, version);
        if version.0 < 5 {write_bool(&mut data, self.triplet_feel != TripletFeel::None);}
        if version.0 >= 4 {self.write_lyrics(&mut data);}
        if version > (5,0,0) {self.write_rse_master_effect(&mut data);}
        if version.0 >= 5 {
            self.write_page_setup(&mut data);
            write_int_byte_size_string(&mut data, &self.tempo_name);
        }
        write_i32(&mut data, self.tempo.to_i32().unwrap());
        if version > (5,0,0) {write_bool(&mut data, self.hide_tempo);}
        write_i32(&mut data, self.key.key.to_i32().unwrap());
        if version.0 >= 4 {write_signed_byte(&mut data, 0);} //octave
        self.write_midi_channels(&mut data); //TODO: fixme for writing
        //return data;
        if version.0 == 5 {
            self.write_directions(&mut data);
            self.write_master_reverb(&mut data);
        }
        write_i32(&mut data, self.tracks[0].measures.len().to_i32().unwrap());
        write_i32(&mut data, self.tracks.len().to_i32().unwrap());
        self.write_measure_headers(&mut data, &version);
        self.write_tracks(&mut data, &version);
        self.write_measures(&mut data, &version);
        write_i32(&mut data, 0);
        data
    }
pub fn write ( & self , version : ( u8 , u8 , u8 ) , clipboard : Option < bool > ) -> Vec < u8 > { let mut data : Vec < u8 > = Vec :: with_capacity ( 8388608 ) ; //capacity of 8MB, should be sufficient write_version ( & mut data , version ) ; if clipboard . is_some ( ) && clipboard . unwrap ( ) && version . 0 >= 4 { self . write_clipboard ( & mut data , & version ) ; } self . write_info ( & mut data , version ) ; if version . 0 < 5 { write_bool ( & mut data , self . triplet_feel != TripletFeel :: None ) ; } if version . 0 >= 4 { self . write_lyrics ( & mut data ) ; } if version > ( 5 , 0 , 0 ) { self . write_rse_master_effect ( & mut data ) ; } if version . 0 >= 5 { self . write_page_setup ( & mut data ) ; write_int_byte_size_string ( & mut data , & self . tempo_name ) ; } write_i32 ( & mut data , self . tempo . to_i32 ( ) . unwrap ( ) ) ; if version > ( 5 , 0 , 0 ) { write_bool ( & mut data , self . hide_tempo ) ; } write_i32 ( & mut data , self . key . key . to_i32 ( ) . unwrap ( ) ) ; if version . 0 >= 4 { write_signed_byte ( & mut data , 0 ) ; } //octave self . write_midi_channels ( & mut data ) ; //TODO: fixme for writing //return data; if version . 0 == 5 { self . write_directions ( & mut data ) ; self . write_master_reverb ( & mut data ) ; } write_i32 ( & mut data , self . tracks [ 0 ] . measures . len ( ) . to_i32 ( ) . unwrap ( ) ) ; write_i32 ( & mut data , self . tracks . len ( ) . to_i32 ( ) . unwrap ( ) ) ; self . write_measure_headers ( & mut data , & version ) ; self . write_tracks ( & mut data , & version ) ; self . write_measures ( & mut data , & version ) ; write_i32 ( & mut data , 0 ) ; data }
Write data to a Vec<u8>, you are free to use the encoded data to write it in a file or in a database or do something else.
Write data to a Vec<u8 > you are free to use the encoded data to write it in a file or in a database or do something else .
&self
version
(u8,u8,u8)
clipboard
Option<bool>
&self
version
(u8,u8,u8)
clipboard
Option<bool>