pub fn create_block(block_device_config: BlockDeviceConfig) -> Result<Block> {
        // check if the path exists
        let path_on_host = PathBuf::from(&block_device_config.path_on_host);
        if !path_on_host.exists() {
            return Err(DriveError::InvalidBlockDevicePath(format!(
                "{}",
                path_on_host.display()
            )));
        }

        let rate_limiter = block_device_config
            .rate_limiter
            .map(super::RateLimiterConfig::try_into)
            .transpose()
            .map_err(DriveError::CreateRateLimiter)?;

        // Create and return the Block device
        devices::virtio::Block::new(
            block_device_config.drive_id,
            block_device_config.partuuid,
            block_device_config.cache_type,
            block_device_config.path_on_host,
            block_device_config.is_read_only,
            block_device_config.is_root_device,
            rate_limiter.unwrap_or_default(),
            block_device_config.file_engine_type,
        )
        .map_err(DriveError::CreateBlockDevice)
    }
/// Creates a Block device from a BlockDeviceConfig.
Creates a Block device from a BlockDeviceConfig.
Creates a Block device from a BlockDeviceConfig .
pub fn create_block(block_device_config: BlockDeviceConfig) -> Result<Block> {
        // check if the path exists
        let path_on_host = PathBuf::from(&block_device_config.path_on_host);
        if !path_on_host.exists() {
            return Err(DriveError::InvalidBlockDevicePath(format!(
                "{}",
                path_on_host.display()
            )));
        }
        let rate_limiter = block_device_config
            .rate_limiter
            .map(super::RateLimiterConfig::try_into)
            .transpose()
            .map_err(DriveError::CreateRateLimiter)?;
        // Create and return the Block device
        devices::virtio::Block::new(
            block_device_config.drive_id,
            block_device_config.partuuid,
            block_device_config.cache_type,
            block_device_config.path_on_host,
            block_device_config.is_read_only,
            block_device_config.is_root_device,
            rate_limiter.unwrap_or_default(),
            block_device_config.file_engine_type,
        )
        .map_err(DriveError::CreateBlockDevice)
    }
pub fn create_block ( block_device_config : BlockDeviceConfig ) -> Result < Block > { // check if the path exists let path_on_host = PathBuf :: from ( & block_device_config . path_on_host ) ; if ! path_on_host . exists ( ) { return Err ( DriveError :: InvalidBlockDevicePath ( format ! ( " " path_on_host display ( ) ) ) ) ; } let rate_limiter = block_device_config . rate_limiter . map ( super :: RateLimiterConfig :: try_into ) . transpose ( ) . map_err ( DriveError :: CreateRateLimiter ) ? ; // Create and return the Block device devices :: virtio :: Block :: new ( block_device_config . drive_id , block_device_config . partuuid , block_device_config . cache_type , block_device_config . path_on_host , block_device_config . is_read_only , block_device_config . is_root_device , rate_limiter . unwrap_or_default ( ) , block_device_config . file_engine_type , ) . map_err ( DriveError :: CreateBlockDevice ) }
Creates a Block device from a BlockDeviceConfig.
Creates a Block device from a BlockDeviceConfig .
block_device_config
BlockDeviceConfig