Skip to main content

wxtla/images/qcow/
driver.rs

1//! QCOW driver open flow.
2
3use super::{DESCRIPTOR, image::QcowImage};
4use crate::{ByteSourceHandle, DataSource, Driver, OpenOptions, Result};
5
6/// Driver for QCOW image files.
7#[derive(Debug, Default, Clone, Copy)]
8pub struct QcowDriver;
9
10impl QcowDriver {
11  /// Create a new QCOW driver.
12  pub const fn new() -> Self {
13    Self
14  }
15
16  /// Open a QCOW image.
17  pub fn open(source: ByteSourceHandle) -> Result<QcowImage> {
18    QcowImage::open(source)
19  }
20}
21
22impl Driver for QcowDriver {
23  fn descriptor(&self) -> crate::FormatDescriptor {
24    DESCRIPTOR
25  }
26
27  fn open(
28    &self, source: ByteSourceHandle, options: OpenOptions<'_>,
29  ) -> Result<Box<dyn DataSource>> {
30    Ok(Box::new(QcowImage::open_with_hints(source, options.hints)?))
31  }
32}