use crate::{
macros::{
impl_box_once_conversions,
impl_common_name_methods,
impl_common_new_methods,
},
suppliers::macros::impl_supplier_debug_display,
suppliers::supplier_once::SupplierOnce,
tasks::callable_once::{
BoxCallableOnce,
CallableOnce,
LocalBoxCallableOnce,
},
};
mod box_runnable_once;
pub use box_runnable_once::BoxRunnableOnce;
mod local_box_runnable_once;
pub use local_box_runnable_once::LocalBoxRunnableOnce;
pub trait RunnableOnce<E> {
fn run(self) -> Result<(), E>;
fn into_box(self) -> BoxRunnableOnce<E>
where
Self: Sized + Send + 'static,
{
BoxRunnableOnce::new(move || self.run())
}
fn into_local_box(self) -> LocalBoxRunnableOnce<E>
where
Self: Sized + 'static,
{
LocalBoxRunnableOnce::new(move || self.run())
}
fn into_fn(self) -> impl FnOnce() -> Result<(), E>
where
Self: Sized + 'static,
{
move || self.run()
}
fn to_box(&self) -> BoxRunnableOnce<E>
where
Self: Clone + Send + Sized + 'static,
{
self.clone().into_box()
}
fn to_local_box(&self) -> LocalBoxRunnableOnce<E>
where
Self: Clone + Sized + 'static,
{
self.clone().into_local_box()
}
fn to_fn(&self) -> impl FnOnce() -> Result<(), E>
where
Self: Clone + Sized + 'static,
{
self.clone().into_fn()
}
fn into_callable(self) -> BoxCallableOnce<(), E>
where
Self: Sized + Send + 'static,
{
BoxCallableOnce::new(move || self.run())
}
fn into_local_callable(self) -> LocalBoxCallableOnce<(), E>
where
Self: Sized + 'static,
{
LocalBoxCallableOnce::new(move || self.run())
}
}