Skip to main content

CfResultExt

Trait CfResultExt 

Source
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))
}

Required Methods§

Source

fn cf(self) -> Result<T, CfError>

Convert a worker::Result<T> into Result<T, CfError>, which can then be propagated with ? into any function returning Result<_, ServerFnError>.

Implementations on Foreign Types§

Source§

impl<T> CfResultExt<T> for Result<T, Error>

Source§

fn cf(self) -> Result<T, CfError>

Source§

impl<T> CfResultExt<T> for Result<T, KvError>

Source§

fn cf(self) -> Result<T, CfError>

Source§

impl<T> CfResultExt<T> for Result<T, Error>

Source§

fn cf(self) -> Result<T, CfError>

Implementors§