next-web-macros 0.2.0

Provide a series of commonly used macros
Documentation
use from_attr::FromAttr;
use syn::{parse_quote, Expr, ExprPath};

#[derive(FromAttr)]
#[attribute(idents = [value])]
pub(crate) struct RetryAttr {
    #[attribute(default = default_max_attempts())]
    pub(crate) max_attempts: Expr,

    #[attribute(default = default_delay())]
    pub(crate) delay: Expr,

    pub(crate) backoff: Option<ExprPath>,

    pub(crate) retry_for: Vec<Expr>,

    pub(crate) multiplier: Option<Expr>,
}

fn default_max_attempts() -> Expr {
    parse_quote!(1)
}

fn default_delay() -> Expr {
    parse_quote!(1000)
}

impl Default for RetryAttr {
    fn default() -> Self {
        Self {
            max_attempts: default_max_attempts(),
            delay: default_delay(),
            backoff: None,
            retry_for: Vec::new(),
            multiplier: None,
        }
    }
}