1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Structures and enums related to external memory errors.

use crate::device::OutOfMemory;

#[derive(Clone, Debug, PartialEq, thiserror::Error)]
/// Error while enumerating external image properties. Returned from [PhysicalDevice::external_image_properties][crate::adapter::PhysicalDevice::external_image_properties].
pub enum ExternalImagePropertiesError {
    /// Out of either host or device memory.
    #[error(transparent)]
    OutOfMemory(#[from] OutOfMemory),

    /// Requested image format not supported in combination with other parameters.
    #[error("Format not supported")]
    FormatNotSupported,
}

#[derive(Clone, Debug, PartialEq, thiserror::Error)]
/// Error while creating and allocating or importing an external buffer.
pub enum ExternalResourceError {
    /// Out of either host or device memory.
    #[error(transparent)]
    OutOfMemory(#[from] OutOfMemory),

    /// Cannot create any more objects.
    #[error("Too many objects")]
    TooManyObjects,

    /// All the desired memory type ids are invalid for the implementation..
    #[error("No valid memory type id among the desired ones")]
    NoValidMemoryTypeId,

    /// Invalid external handle.
    #[error("The used external handle or the combination of them is invalid")]
    InvalidExternalHandle,
}

#[derive(Clone, Debug, PartialEq, thiserror::Error)]
/// Error while exporting a memory. Returned from [Device::export_memory][crate::device::Device::export_memory].
pub enum ExternalMemoryExportError {
    /// Too many objects.
    #[error("Too many objects")]
    TooManyObjects,

    /// Out of host memory.
    #[error("Out of host memory")]
    OutOfHostMemory,

    /// Invalid external handle.
    #[error("Invalid external handle")]
    InvalidExternalHandle,
}