pub trait CfResultExt<T> {
// Required method
fn cf(self) -> Result<T, CfError>;
}Expand description
Extension trait for worker::Result<T> that converts errors into a type
compatible with ServerFnError via the ? operator.
§Example
ⓘ
use dioxus_cloudflare::prelude::*;
#[server]
pub async fn get_count() -> Result<i64, ServerFnError> {
let kv = cf::env().kv("COUNTS").cf()?;
let val = kv.get("total").text().await.cf()?;
Ok(val.unwrap_or_default().parse().unwrap_or(0))
}