#[cfg(any(feature = "initial_value", doc))]
use serde::Deserialize;
use serde::{de::DeserializeOwned, Serialize};
#[cfg(not(target_family = "wasm"))]
use tauri::{AppHandle, Error, Wry};
#[cfg(not(target_family = "wasm"))]
#[doc(cfg(not(target_family = "wasm")))]
pub use emit::*;
#[cfg(any(target_family = "wasm", doc))]
#[doc(cfg(target_family = "wasm"))]
pub use listen::*;
#[cfg(doc)]
use tauri_interop_macro::{Emit, EmitField, Event, Listen, ListenField};
#[cfg(not(target_family = "wasm"))]
#[doc(cfg(not(target_family = "wasm")))]
mod emit;
#[cfg(any(target_family = "wasm", doc))]
#[doc(cfg(target_family = "wasm"))]
mod listen;
#[allow(clippy::needless_doctest_main)]
pub trait Field<P>
where
P: Parent,
Self::Type: Default + Clone + Serialize + DeserializeOwned + 'static,
{
type Type;
const EVENT_NAME: &'static str;
#[allow(async_fn_in_trait)]
#[cfg(any(all(target_family = "wasm", feature = "initial_value"), doc))]
#[doc(cfg(all(target_family = "wasm", feature = "initial_value")))]
async fn get_value() -> Result<Self::Type, EventError>;
#[cfg(not(target_family = "wasm"))]
#[doc(cfg(not(target_family = "wasm")))]
fn emit(parent: &P, handle: &AppHandle<Wry>) -> Result<(), Error>;
#[cfg(not(target_family = "wasm"))]
#[doc(cfg(not(target_family = "wasm")))]
fn update(s: &mut P, handle: &AppHandle<Wry>, v: Self::Type) -> Result<(), Error>;
}
#[cfg(any(feature = "initial_value", doc))]
#[doc(cfg(feature = "initial_value"))]
#[derive(Debug, Serialize, Deserialize, thiserror::Error)]
pub enum EventError {
#[error("{0} is not as tauri state registered")]
StateIsNotRegistered(String),
}