pub fn save_into_file(&mut self, config: &Config) {
        // path to the file
        let path_str = config.filename(self.static_properties.id);
        let path = Path::new(&path_str);

        // while there are packets to write
        while self.next_write_position != self.window_position {
            // get the following one and remove it from the cache memory
            let buffer = self.parts_received.remove(&self.next_write_position).expect("Part to write is not within the map");
            // make sure the file is open
            self.file = Some(match self.file.take() {
                Some(f) => f,
                None => OpenOptions::new().write(true)
                                          .append(true)
                                          .create(true)
                                          .open(path).expect("Can't open file for write")
            });
            let file = self.file.as_mut().unwrap();
            // write the content
            let wrote = file.write(&buffer).expect("Can't write to the output file");
            config.vlog(&format!(
                "Connection {} wrote {}b into file for packet seq {}",
                self.static_properties.id,
                wrote,
                self.next_write_position
            ));
            // move to the following packet
            let new_write_pos = Wrapping(self.next_write_position) + Wrapping::<u16>(1);
            self.next_write_position = new_write_pos.0;
        }
    }
/// Write data from the cache memory into the file if present.
Write data from the cache memory into the file if present.
Write data from the cache memory into the file if present .
pub fn save_into_file(&mut self, config: &Config) {
        // path to the file
        let path_str = config.filename(self.static_properties.id);
        let path = Path::new(&path_str);
        // while there are packets to write
        while self.next_write_position != self.window_position {
            // get the following one and remove it from the cache memory
            let buffer = self.parts_received.remove(&self.next_write_position).expect("Part to write is not within the map");
            // make sure the file is open
            self.file = Some(match self.file.take() {
                Some(f) => f,
                None => OpenOptions::new().write(true)
                                          .append(true)
                                          .create(true)
                                          .open(path).expect("Can't open file for write")
            });
            let file = self.file.as_mut().unwrap();
            // write the content
            let wrote = file.write(&buffer).expect("Can't write to the output file");
            config.vlog(&format!(
                "Connection {} wrote {}b into file for packet seq {}",
                self.static_properties.id,
                wrote,
                self.next_write_position
            ));
            // move to the following packet
            let new_write_pos = Wrapping(self.next_write_position) + Wrapping::<u16>(1);
            self.next_write_position = new_write_pos.0;
        }
    }
pub fn save_into_file ( & mut self , config : & Config ) { // path to the file let path_str = config . filename ( self . static_properties . id ) ; let path = Path :: new ( & path_str ) ; // while there are packets to write while self . next_write_position != self . window_position { // get the following one and remove it from the cache memory let buffer = self . parts_received . remove ( & self . next_write_position ) . expect ( " " ) ; // make sure the file is open self . file = Some ( match self . file . take ( ) { Some ( f ) => f , None => OpenOptions :: new ( ) . write ( true ) . append ( true ) . create ( true ) . open ( path ) . expect ( " " ) } ) ; let file = self . file . as_mut ( ) . unwrap ( ) ; // write the content let wrote = file . write ( & buffer ) . expect ( " " ) ; config . vlog ( & format ! ( " " self static_properties id wrote self next_write_position ) ) ; // move to the following packet let new_write_pos = Wrapping ( self . next_write_position ) + Wrapping :: < u16 > ( 1 ) ; self . next_write_position = new_write_pos . 0 ; } }
Write data from the cache memory into the file if present.
Write data from the cache memory into the file if present .
&mut self
config
&Config
&mut self
config
&Config