pub trait Field<P>{
type Type;
const EVENT_NAME: &'static str;
// Required methods
async fn get_value() -> Result<Self::Type, EventError>;
fn emit(parent: &P, handle: &AppHandle<Wry>) -> Result<(), Error>;
fn update(
s: &mut P,
handle: &AppHandle<Wry>,
v: Self::Type,
) -> Result<(), Error>;
}Available on crate feature
event only.Expand description
Trait defining a Field to a related struct implementing Parent with the related Field::Type
When using Event, Emit or Listen, for each field of the struct, a struct named after the field is generated. The field naming is snake_case to PascalCase, but because of the possibility that the type and the field name are the same, the generated field has a “F” appended at the beginning to separate each other and avoid type collision.
use serde::{Deserialize, Serialize};
use tauri_interop::Event;
#[derive(Default, Clone, Serialize, Deserialize)]
struct Bar {
foo: u16
}
#[derive(Event)]
struct Test {
bar: Bar
}
#[cfg(feature = "initial_value")]
impl tauri_interop::event::ManagedEmit for Test {}
fn main() {
let _ = test::FBar;
}Required Associated Constants§
Sourceconst EVENT_NAME: &'static str
const EVENT_NAME: &'static str
The event of the field
Required Associated Types§
Required Methods§
Sourceasync fn get_value() -> Result<Self::Type, EventError>
Available on target_family="wasm" and crate feature initial_value only.
async fn get_value() -> Result<Self::Type, EventError>
target_family="wasm" and crate feature initial_value only.Tries to retrieve the current value from the backend
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.