diff --git a/src/functions/arg.rs b/src/functions/arg.rs index 7fc0c6c..a4557ba 100644 --- a/src/functions/arg.rs +++ b/src/functions/arg.rs @@ -1,46 +1,19 @@ -mod private { - use crate::{DataType, Type, TypeMap}; - - /// Implemented by types that can be used as an argument in a function annotated with - /// [`specta`](crate::specta). - pub trait FunctionArg { - /// Gets the type of an argument as a [`DataType`]. - /// - /// Some argument types should be ignored (eg Tauri command State), - /// so the value is optional. - fn to_datatype(type_map: &mut TypeMap) -> Option; - } +use crate::{DataType, Type, TypeMap}; + +/// Implemented by types that can be used as an argument in a function annotated with +/// [`specta`](crate::specta). +pub trait FunctionArg { + /// Gets the type of an argument as a [`DataType`]. + /// + /// Some argument types should be ignored (eg Tauri command State), + /// so the value is optional. + fn to_datatype(type_map: &mut TypeMap) -> Option; +} - pub enum FunctionArgMarker {} +pub enum FunctionArgMarker {} - impl FunctionArg for T { - fn to_datatype(type_map: &mut TypeMap) -> Option { - Some(T::reference(type_map, &[]).inner) - } +impl FunctionArg for T { + fn to_datatype(type_map: &mut TypeMap) -> Option { + Some(T::reference(type_map, &[]).inner) } - - #[cfg(feature = "tauri")] - const _: () = { - pub enum FunctionArgTauriMarker {} - - impl FunctionArg for tauri::Window { - fn to_datatype(_: &mut TypeMap) -> Option { - None - } - } - - impl<'r, T: Send + Sync + 'static> FunctionArg for tauri::State<'r, T> { - fn to_datatype(_: &mut TypeMap) -> Option { - None - } - } - - impl FunctionArg for tauri::AppHandle { - fn to_datatype(_: &mut TypeMap) -> Option { - None - } - } - }; } - -pub(crate) use private::FunctionArg; diff --git a/src/functions/mod.rs b/src/functions/mod.rs index 2b74e14..31ab630 100644 --- a/src/functions/mod.rs +++ b/src/functions/mod.rs @@ -3,7 +3,8 @@ mod result; use std::borrow::Cow; -pub(crate) use arg::*; +pub use arg::FunctionArg; + pub(crate) use result::*; use crate::*; diff --git a/src/functions/result.rs b/src/functions/result.rs index fa60caa..a7b01a4 100644 --- a/src/functions/result.rs +++ b/src/functions/result.rs @@ -1,32 +1,28 @@ -mod private { - use std::future::Future; +use std::future::Future; - use crate::{DataType, Type, TypeMap}; +use crate::{DataType, Type, TypeMap}; - /// Implemented by types that can be returned from a function annotated with - /// [`specta`](crate::specta). - pub trait FunctionResult { - /// Gets the type of the result as a [`DataType`]. - fn to_datatype(type_map: &mut TypeMap) -> DataType; - } +/// Implemented by types that can be returned from a function annotated with +/// [`specta`](crate::specta). +pub trait FunctionResult { + /// Gets the type of the result as a [`DataType`]. + fn to_datatype(type_map: &mut TypeMap) -> DataType; +} - pub enum FunctionResultMarker {} - impl FunctionResult for T { - fn to_datatype(type_map: &mut TypeMap) -> DataType { - T::reference(type_map, &[]).inner - } +pub enum FunctionResultMarker {} +impl FunctionResult for T { + fn to_datatype(type_map: &mut TypeMap) -> DataType { + T::reference(type_map, &[]).inner } +} - pub enum FunctionResultFutureMarker {} - impl FunctionResult for F - where - F: Future, - F::Output: Type, - { - fn to_datatype(type_map: &mut TypeMap) -> DataType { - F::Output::reference(type_map, &[]).inner - } +pub enum FunctionResultFutureMarker {} +impl FunctionResult for F +where + F: Future, + F::Output: Type, +{ + fn to_datatype(type_map: &mut TypeMap) -> DataType { + F::Output::reference(type_map, &[]).inner } } - -pub(crate) use private::FunctionResult;