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