pub enum Local {}Expand description
Abstraction over !Send futures.
Use this when your async code runs in single-threaded environments like
Wasm, browser contexts, or single-threaded executors that don’t require
futures to be Send.
§Example
use future_form::{FutureForm, Local};
use futures::future::LocalBoxFuture;
trait Cache<K: FutureForm> {
fn fetch<'a>(&'a self, key: &'a str) -> K::Future<'a, Option<String>>;
}
struct BrowserCache;
// Implement for !Send futures - can be used in Wasm
impl Cache<Local> for BrowserCache {
fn fetch<'a>(&'a self, key: &'a str) -> LocalBoxFuture<'a, Option<String>> {
Local::from_future(async move {
// Simulate fetching from browser storage
Some(format!("value-{}", key))
})
}
}Trait Implementations§
Source§impl FutureForm for Local
impl FutureForm for Local
Source§type Future<'a, T: 'a> = Pin<Box<dyn Future<Output = T> + 'a>>
type Future<'a, T: 'a> = Pin<Box<dyn Future<Output = T> + 'a>>
An abstraction over future types. Read more
Source§fn ready<'a, T>(value: T) -> Self::Future<'a, T>
fn ready<'a, T>(value: T) -> Self::Future<'a, T>
Create this form’s future type from an already-computed value. Read more
Source§fn from_future<'a, T, F>(f: F) -> Self::Future<'a, T>
fn from_future<'a, T, F>(f: F) -> Self::Future<'a, T>
Create this form’s future type from a raw future. Read more
impl Copy for Local
Auto Trait Implementations§
impl Freeze for Local
impl RefUnwindSafe for Local
impl Send for Local
impl Sync for Local
impl Unpin for Local
impl UnsafeUnpin for Local
impl UnwindSafe for Local
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