Remove actions (moved to leptos_server)

This commit is contained in:
Greg Johnston 2022-11-03 21:07:05 -04:00
parent 8873ddc40a
commit d5e3661bcf
2 changed files with 0 additions and 34 deletions

View file

@ -1,32 +0,0 @@
use std::{future::Future, rc::Rc};
use crate::{PinnedFuture, Request, Response};
#[derive(Clone)]
pub struct Action {
f: Rc<dyn Fn(&Request) -> PinnedFuture<Response>>,
}
impl Action {
pub async fn send(&self, req: &Request) -> Response {
(self.f)(req).await
}
}
impl<F, Fu> From<F> for Action
where
F: Fn(&Request) -> Fu + 'static,
Fu: Future<Output = Response> + 'static,
{
fn from(f: F) -> Self {
Self {
f: Rc::new(move |req| Box::pin(f(req))),
}
}
}
impl std::fmt::Debug for Action {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Action").finish()
}
}

View file

@ -1,9 +1,7 @@
mod action;
mod loader;
use std::{future::Future, pin::Pin};
pub use action::*;
pub use loader::*;
pub(crate) type PinnedFuture<T> = Pin<Box<dyn Future<Output = T>>>;