pub fn insert(&self, device: Arc<Mutex<dyn BusDevice>>, base: u64, len: u64) -> Result<()> {
        if len == 0 {
            return Err(Error::ZeroSizedRange);
        }

        // Reject all cases where the new device's range overlaps with an existing device.
        if self
            .devices
            .read()
            .unwrap()
            .iter()
            .any(|(range, _dev)| range.overlaps(base, len))
        {
            return Err(Error::Overlap);
        }

        if self
            .devices
            .write()
            .unwrap()
            .insert(BusRange { base, len }, Arc::downgrade(&device))
            .is_some()
        {
            return Err(Error::Overlap);
        }

        Ok(())
    }
/// Puts the given device at the given address space.
Puts the given device at the given address space.
Puts the given device at the given address space .
pub fn insert(&self, device: Arc<Mutex<dyn BusDevice>>, base: u64, len: u64) -> Result<()> {
        if len == 0 {
            return Err(Error::ZeroSizedRange);
        }
        // Reject all cases where the new device's range overlaps with an existing device.
        if self
            .devices
            .read()
            .unwrap()
            .iter()
            .any(|(range, _dev)| range.overlaps(base, len))
        {
            return Err(Error::Overlap);
        }
        if self
            .devices
            .write()
            .unwrap()
            .insert(BusRange { base, len }, Arc::downgrade(&device))
            .is_some()
        {
            return Err(Error::Overlap);
        }
        Ok(())
    }
pub fn insert ( & self , device : Arc < Mutex < dyn BusDevice > > , base : u64 , len : u64 ) -> Result < ( ) > { if len == 0 { return Err ( Error :: ZeroSizedRange ) ; } // Reject all cases where the new device's range overlaps with an existing device. if self . devices . read ( ) . unwrap ( ) . iter ( ) . any ( | ( range , _dev ) | range . overlaps ( base , len ) ) { return Err ( Error :: Overlap ) ; } if self . devices . write ( ) . unwrap ( ) . insert ( BusRange { base , len } , Arc :: downgrade ( & device ) ) . is_some ( ) { return Err ( Error :: Overlap ) ; } Ok ( ( ) ) }
Puts the given device at the given address space.
Puts the given device at the given address space .
&self
device
Arc<Mutex<dyn BusDevice>>
base
u64
len
u64
&self
device
Arc<Mutex<dyn BusDevice>>
base
u64
len
u64