Trait vm_memory::guest_memory::GuestMemoryIterator

source ·
pub trait GuestMemoryIterator<'a, R: 'a> {
    type Iter: Iterator<Item = &'a R>;
}
Expand description

Lifetime generic associated iterators. The actual iterator type is defined through associated item Iter, for example:

// Declare the relevant Region and Memory types
struct MyGuestRegion {/* fields omitted */}
struct MyGuestMemory {/* fields omitted */}

// Make an Iterator type to iterate over the Regions
struct MyGuestMemoryIter<'a> {/* fields omitted */}
impl<'a> Iterator for MyGuestMemoryIter<'a> {
    type Item = &'a MyGuestRegion;
    fn next(&mut self) -> Option<&'a MyGuestRegion> {
        // ...
    }
}

// Associate the Iter type with the Memory type
impl<'a> GuestMemoryIterator<'a, MyGuestRegion> for MyGuestMemory {
    type Iter = MyGuestMemoryIter<'a>;
}

Required Associated Types§

source

type Iter: Iterator<Item = &'a R>

Type of the iter method’s return value.

Implementors§

source§

impl<'a, B: 'a> GuestMemoryIterator<'a, GuestRegionMmap<B>> for GuestMemoryMmap<B>

§

type Iter = Iter<'a, B>