Skip to main content

ferroui_base/input/
data_format_kind.rs

1/// Represents the kind of a [`DataFormat`](super::DataFormat).
2#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
3#[repr(i32)]
4pub enum DataFormatKind {
5    /// The data format is specific to the application. The exact format
6    /// name used internally will vary depending on the platform.
7    ///
8    /// Such a format is created using
9    /// [`DataFormat::create_bytes_application_format`](super::DataFormat::create_bytes_application_format)
10    /// or [`DataFormat::create_string_application_format`](super::DataFormat::create_string_application_format).
11    Application = 0,
12
13    /// The data format is specific to the current platform. Any other
14    /// application using the same identifier will be able to access it.
15    ///
16    /// Such a format is created using
17    /// [`DataFormat::create_bytes_platform_format`](super::DataFormat::create_bytes_platform_format)
18    /// or [`DataFormat::create_string_platform_format`](super::DataFormat::create_string_platform_format).
19    Platform = 1,
20
21    /// The data format is cross-platform and supported directly by the
22    /// framework. Such formats include [`DataFormat::text`](super::DataFormat::text)
23    /// and [`DataFormat::bitmap`](super::DataFormat::bitmap).
24    ///
25    /// It is not possible to create such a format directly.
26    Universal = 2,
27
28    /// The data format is only usable within the current process. It never
29    /// crosses process or serialization boundaries.
30    ///
31    /// Such a format is created using
32    /// [`DataFormat::create_in_process_format`](super::DataFormat::create_in_process_format).
33    InProcess = 3,
34}
35
36impl DataFormatKind {
37    /// The name of the kind.
38    pub fn name(self) -> &'static str {
39        match self {
40            DataFormatKind::Application => "Application",
41            DataFormatKind::Platform => "Platform",
42            DataFormatKind::Universal => "Universal",
43            DataFormatKind::InProcess => "InProcess",
44        }
45    }
46}
47
48impl std::fmt::Display for DataFormatKind {
49    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50        f.write_str(self.name())
51    }
52}