//! 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)
}
