apollo-errors-derive 0.4.0

Proc macro for deriving apollo-errors::Error trait
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! JSON-RPC code attribute parsing

use syn::{Attribute, Result};

/// Parse `#[jsonrpc_code(code)]` attribute
pub(crate) fn parse_jsonrpc_code(attrs: &[Attribute]) -> Result<Option<i32>> {
    for attr in attrs {
        if attr.path().is_ident("jsonrpc_code") {
            let lit: syn::LitInt = attr.parse_args()?;
            let code: i32 = lit.base10_parse()?;

            return Ok(Some(code));
        }
    }
    Ok(None)
}