warpgate_api/
lib.rs

1mod host;
2mod host_funcs;
3mod locator;
4mod locator_error;
5mod virtual_path;
6
7pub use anyhow::anyhow;
8pub use host::*;
9pub use host_funcs::*;
10pub use locator::*;
11pub use locator_error::*;
12pub use starbase_id::*;
13pub use virtual_path::*;
14
15/// Wrap a struct with common derives and serde required attributes.
16#[macro_export]
17macro_rules! api_struct {
18    ($struct:item) => {
19        #[derive(Clone, Debug, Default, serde::Deserialize, PartialEq, serde::Serialize)]
20        #[cfg_attr(feature = "schematic", derive(schematic::Schematic))]
21        $struct
22    };
23}
24
25/// Wrap an enum with common derives and serde required attributes.
26#[macro_export]
27macro_rules! api_enum {
28    ($struct:item) => {
29        #[derive(Clone, Debug, serde::Deserialize, PartialEq, serde::Serialize)]
30        #[cfg_attr(feature = "schematic", derive(schematic::Schematic))]
31        $struct
32    };
33}
34
35/// Wrap a unit-only enum with common derives and serde required attributes.
36#[macro_export]
37macro_rules! api_unit_enum {
38    ($struct:item) => {
39        #[derive(Clone, Copy, Debug, Default, serde::Deserialize, PartialEq, serde::Serialize)]
40        #[serde(rename_all = "kebab-case")]
41        #[cfg_attr(feature = "schematic", derive(schematic::Schematic))]
42        $struct
43    };
44}
45
46api_struct!(
47    /// Represents an empty input.
48    pub struct EmptyInput {}
49);
50
51/// Represents any result (using `anyhow`).
52pub type AnyResult<T> = anyhow::Result<T>;