pub fn add(&mut self, cfg: VsockDeviceConfig) -> result::Result<(), VsockError> {
        if self.contains_cid(cfg.guest_cid) {
            return Err(VsockError::GuestCIDAlreadyInUse(cfg.guest_cid));
        }

        match self
            .configs
            .iter()
            .position(|cfg_from_list| cfg_from_list.id.as_str() == cfg.id.as_str())
        {
            Some(index) => self.configs[index] = cfg,
            None => self.configs.push(cfg),
        }

        Ok(())
    }
/// Adds `vsock_config` in the list of vsock device configurations.
/// If an entry with the same id already exists, it will update the existing
/// entry.
Adds `vsock_config` in the list of vsock device configurations.
If an entry with the same id already exists, it will update the existing
entry.
Adds ` vsock_config ` in the list of vsock device configurations . If an entry with the same id already exists it will update the existing entry .
pub fn add(&mut self, cfg: VsockDeviceConfig) -> result::Result<(), VsockError> {
        if self.contains_cid(cfg.guest_cid) {
            return Err(VsockError::GuestCIDAlreadyInUse(cfg.guest_cid));
        }
        match self
            .configs
            .iter()
            .position(|cfg_from_list| cfg_from_list.id.as_str() == cfg.id.as_str())
        {
            Some(index) => self.configs[index] = cfg,
            None => self.configs.push(cfg),
        }
        Ok(())
    }
pub fn add ( & mut self , cfg : VsockDeviceConfig ) -> result :: Result < ( ) , VsockError > { if self . contains_cid ( cfg . guest_cid ) { return Err ( VsockError :: GuestCIDAlreadyInUse ( cfg . guest_cid ) ) ; } match self . configs . iter ( ) . position ( | cfg_from_list | cfg_from_list . id . as_str ( ) == cfg . id . as_str ( ) ) { Some ( index ) => self . configs [ index ] = cfg , None => self . configs . push ( cfg ) , } Ok ( ( ) ) }
Adds `vsock_config` in the list of vsock device configurations.
Adds ` vsock_config ` in the list of vsock device configurations .
&mut self
cfg
VsockDeviceConfig
&mut self
cfg
VsockDeviceConfig