Files
archived-tauri-bindgen/crates/gen-host/tests/sync/conventions.rs
Jonas Kruckenberg 3811b479e5 cleanup
2023-09-14 03:15:14 -06:00

161 lines
5.6 KiB
Rust

#[allow(unused_imports, unused_variables, dead_code)]
#[rustfmt::skip]
pub mod conventions {
use ::tauri_bindgen_host::serde;
use ::tauri_bindgen_host::bitflags;
#[derive(serde::Deserialize)]
#[derive(Debug, Clone, PartialEq)]
pub struct LudicrousSpeed {
pub how_fast_are_you_going: u32,
pub i_am_going_extremely_slow: u64,
}
pub trait Conventions: Sized {
fn kebab_case(&self);
fn foo(&self, x: LudicrousSpeed);
fn function_with_underscores(&self);
fn function_with_no_weird_characters(&self);
fn apple(&self);
fn apple_pear(&self);
fn apple_pear_grape(&self);
fn a0(&self);
fn is_xml(&self);
fn explicit(&self);
fn explicit_snake(&self);
fn bool(&self);
}
pub fn add_to_router<T, U>(
router: &mut ::tauri_bindgen_host::ipc_router_wip::Router<T>,
get_cx: impl Fn(&T) -> &U + Send + Sync + 'static,
) -> Result<(), ::tauri_bindgen_host::ipc_router_wip::Error>
where
T: Send + Sync + 'static,
U: Conventions + Send + Sync + 'static,
{
let wrapped_get_cx = ::std::sync::Arc::new(get_cx);
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"kebab_case",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.kebab_case())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"foo",
move |
ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>,
p: LudicrousSpeed|
{
let ctx = get_cx(ctx.data());
Ok(ctx.foo(p))
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"function_with_underscores",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.function_with_underscores())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"function_with_no_weird_characters",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.function_with_no_weird_characters())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"apple",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.apple())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"apple_pear",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.apple_pear())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"apple_pear_grape",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.apple_pear_grape())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"a0",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.a0())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"is_xml",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.is_xml())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"explicit",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.explicit())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"explicit_snake",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.explicit_snake())
},
)?;
let get_cx = ::std::sync::Arc::clone(&wrapped_get_cx);
router
.define(
"conventions",
"bool",
move |ctx: ::tauri_bindgen_host::ipc_router_wip::Caller<T>, p: ()| {
let ctx = get_cx(ctx.data());
Ok(ctx.bool())
},
)?;
Ok(())
}
}