#[macro_export]
macro_rules! spawn_transaction_no_commit_send_result {
($shared_config:ident, bounded, $tx:ident, $fetch_fn:expr) => {
tokio::spawn(async move {
let db_pool = $shared_config.read().await.db_pool.clone();
let result = async {
let mut transaction = db_pool.begin().await?;
$fetch_fn(&mut transaction).await
}
.await;
let _ = $tx.send(result).await;
});
};
($shared_config:ident, unbounded, $tx:ident, $fetch_fn:expr) => {
tokio::spawn(async move {
let db_pool = $shared_config.read().await.db_pool.clone();
tokio::time::sleep(std::time::Duration::from_secs(0)).await;
let result = async {
let mut transaction = db_pool.begin().await?;
$fetch_fn(&mut transaction).await
}
.await;
let _ = $tx.send(result);
});
};
}
#[macro_export]
macro_rules! impl_valid_asynchronous_macro_never_called {
($type:ty) => {
impl open_timeline_gui_core::ValidAsynchronous for $type {
type Error = open_timeline_crud::CrudError;
fn is_valid_asynchronous(&self) -> Option<Result<(), Self::Error>> {
panic!()
}
fn check_for_asynchronous_validity_response(&mut self) {
panic!()
}
fn trigger_asynchronous_validity_update(&mut self) {
panic!()
}
}
};
}
#[macro_export]
macro_rules! impl_valid_synchronous_macro_never_called {
($type:ty) => {
impl open_timeline_gui_core::ValidSynchronous for $type {
fn is_valid_synchronous(&self) -> bool {
panic!()
}
fn update_validity_synchronous(&mut self) {
panic!()
}
fn validity_synchronous(&self) -> open_timeline_gui_core::ValiditySynchronous {
panic!()
}
}
};
}
#[macro_export]
macro_rules! impl_is_valid_method_for_iterable {
($iterable:expr) => {{
for validity in $iterable {
match validity {
open_timeline_gui_core::ValidityAsynchronous::Invalid(error) => {
return open_timeline_gui_core::ValidityAsynchronous::Invalid(error);
}
open_timeline_gui_core::ValidityAsynchronous::Waiting => {
return open_timeline_gui_core::ValidityAsynchronous::Waiting;
}
open_timeline_gui_core::ValidityAsynchronous::Valid => continue,
}
}
open_timeline_gui_core::ValidityAsynchronous::Valid
}};
}