@@ -201,63 +201,8 @@ pub trait GuestMemory<'a> {
201201 /// Gets an iterator over the entries in the collection.
202202 fn iter ( & ' a self ) -> Self :: I ;
203203
204- /// Perform the specified action on each region.
205- /// It only walks children of current region and do not step into sub regions.
206- fn with_regions < F , E > ( & self , cb : F ) -> std:: result:: Result < ( ) , E >
207- where
208- F : Fn ( usize , & Self :: R ) -> std:: result:: Result < ( ) , E > ;
209-
210- /// Perform the specified action on each region mutably.
211- /// It only walks children of current region and do not step into sub regions.
212- fn with_regions_mut < F , E > ( & self , cb : F ) -> std:: result:: Result < ( ) , E >
213- where
214- F : FnMut ( usize , & Self :: R ) -> std:: result:: Result < ( ) , E > ;
215-
216- /// Applies two functions, specified as callbacks, on the inner memory regions.
217- ///
218- /// # Arguments
219- /// * `init` - Starting value of the accumulator for the `foldf` function.
220- /// * `mapf` - "Map" function, applied to all the inner memory regions. It returns an array of
221- /// the same size as the memory regions array, containing the function's results
222- /// for each region.
223- /// * `foldf` - "Fold" function, applied to the array returned by `mapf`. It acts as an
224- /// operator, applying itself to the `init` value and to each subsequent elemnent
225- /// in the array returned by `mapf`.
226- ///
227- /// # Examples
228- ///
229- /// * Compute the total size of all memory mappings in KB by iterating over the memory regions
230- /// and dividing their sizes to 1024, then summing up the values in an accumulator.
231- ///
232- /// ```
233- /// # #[cfg(feature = "backend-mmap")]
234- /// # fn test_map_fold() -> Result<(), ()> {
235- /// # use vm_memory::{GuestAddress, GuestMemory, GuestMemoryRegion, mmap::GuestMemoryMmap};
236- /// let start_addr1 = GuestAddress(0x0);
237- /// let start_addr2 = GuestAddress(0x400);
238- /// let mem = GuestMemoryMmap::new(&vec![(start_addr1, 1024), (start_addr2, 2048)]).unwrap();
239- /// let total_size = mem.map_and_fold(
240- /// 0,
241- /// |(_, region)| region.len() / 1024,
242- /// |acc, size| acc + size
243- /// );
244- /// println!("Total memory size = {} KB", total_size);
245- /// Ok(())
246- /// # }
247- /// ```
248- fn map_and_fold < F , G , T > ( & self , init : T , mapf : F , foldf : G ) -> T
249- where
250- F : Fn ( ( usize , & Self :: R ) ) -> T ,
251- G : Fn ( T , T ) -> T ;
252-
253204 /// Get maximum (inclusive) address managed by the region.
254- fn end_addr ( & self ) -> GuestAddress {
255- self . map_and_fold (
256- GuestAddress ( 0 ) ,
257- |( _, region) | region. end_addr ( ) ,
258- std:: cmp:: max,
259- )
260- }
205+ fn end_addr ( & self ) -> GuestAddress ;
261206
262207 /// Convert an absolute address into an address space (GuestMemory)
263208 /// to a relative address within this region, or return None if
0 commit comments