pub struct Execute<E>(/* private fields */);Expand description
Wraps a function or closure as a Service.
Use Execute to turn any async function into a service without defining a custom type.
§Examples
async fn handle_input(data: String) -> String {
format!("Processed: {}", data)
}
let service = Execute::new(handle_input);
let result = service.execute("test".to_string()).await;
assert_eq!(result, "Processed: test");let service = Execute::new(move |x: i32| async move { x * 2 });
let result = service.execute(5).await;
assert_eq!(result, 10);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for Execute<E>where
E: Freeze,
impl<E> RefUnwindSafe for Execute<E>where
E: RefUnwindSafe,
impl<E> Send for Execute<E>where
E: Send,
impl<E> Sync for Execute<E>where
E: Sync,
impl<E> Unpin for Execute<E>where
E: Unpin,
impl<E> UnwindSafe for Execute<E>where
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<In, Out, T> DynamicServiceExt<In, Out> for T
impl<In, Out, T> DynamicServiceExt<In, Out> for T
Source§fn into_dynamic(self) -> DynamicService<In, Out>
fn into_dynamic(self) -> DynamicService<In, Out>
Available on crate features
dynamic-service only.Converts this service into a type-erased
DynamicService.