imago/format/
mod.rs

1//! Core functionality.
2//!
3//! Provides access to different image formats via `FormatAccess` objects.
4
5pub mod access;
6pub mod builder;
7pub mod drivers;
8pub mod gate;
9#[cfg(feature = "sync-wrappers")]
10pub mod sync_wrappers;
11pub mod wrapped;
12
13/// List of imago formats.
14#[derive(Clone, Copy, Debug, Eq, PartialEq)]
15#[non_exhaustive]
16pub enum Format {
17    /// Raw format (no metadata at all, everything stored 1:1)
18    Raw,
19
20    /// Qcow2 format (version 2 or 3)
21    Qcow2,
22
23    /// VMDK format
24    Vmdk,
25}
26
27/// Format layer preallocation modes.
28///
29/// When resizing or create an image, this mode determines whether and how the new data range is to
30/// be preallocated.
31#[derive(Clone, Copy, Debug, Eq, PartialEq)]
32#[non_exhaustive]
33pub enum PreallocateMode {
34    /// No preallocation.
35    ///
36    /// Reading the new range may return random data.
37    None,
38
39    /// Ensure range reads as zeroes.
40    ///
41    /// Does not necessarily allocate data, but has to ensure the new range will read back as
42    /// zeroes (e.g. a backing file’s contents must not show through).
43    Zero,
44
45    /// Metadata preallocation.
46    ///
47    /// Do not write data, but ensure all blocks are mapped as data.  For images without a backing
48    /// file, that data must read as zeroes.  For images with a backing file, that data must be the
49    /// same as the backing file’s contents, and zeroes beyond the backing file EOF.
50    FormatAllocate,
51
52    /// Metadata and extent preallocation.
53    ///
54    /// Same as `FormatAllocate`, but also allocate all blocks on the underlying storage.
55    FullAllocate,
56
57    /// Full data preallocation.
58    ///
59    /// Write data to the whole range.  For images without a backing file, that data must read as
60    /// zeroes.  For images with a backing file, that data must be the same as the backing file’s
61    /// contents, and zeroes beyond the backing file EOF.
62    WriteData,
63}