master
Tait Hoyem 2 years ago
parent 4440a4262a
commit e3d9669037

@ -10,11 +10,10 @@
/// ///
/// TODO: Improve error messages. /// TODO: Improve error messages.
use std::collections::HashMap;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use quote::quote; use quote::quote;
use syn::parse::{Parse, ParseStream, Parser, Result}; use syn::parse::Parser;
use syn::{parse, parse_macro_input, punctuated::Punctuated, Attribute, AttributeArgs, Expr, Ident, ItemStruct, Local, Lit, LitStr, NestedMeta, Meta, MetaNameValue, Pat, Stmt, Type, Token, DeriveInput}; use syn::{parse_macro_input, AttributeArgs, ItemStruct, Lit, NestedMeta, Meta, MetaNameValue, Type};
#[derive(Debug, Hash, Eq, PartialEq)] #[derive(Debug, Hash, Eq, PartialEq)]
enum LunanodeRequestParam { enum LunanodeRequestParam {
@ -33,7 +32,7 @@ impl LunanodeRequestParam {
} }
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn lunanode_response(attr: TokenStream, input: TokenStream) -> TokenStream { pub fn lunanode_response(_attr: TokenStream, input: TokenStream) -> TokenStream {
// Get the structs below the macro // Get the structs below the macro
let mut item_struct = parse_macro_input!(input as ItemStruct); let mut item_struct = parse_macro_input!(input as ItemStruct);
// clone the name to keep compiler happy :) // clone the name to keep compiler happy :)
@ -67,7 +66,7 @@ pub fn lunanode_request(attr: TokenStream, input: TokenStream) -> TokenStream {
.into_iter() .into_iter()
.filter_map(|nm| match nm { .filter_map(|nm| match nm {
// Only select certain tokens // Only select certain tokens
NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, eq_token, lit: Lit::Str(lstr) })) => Some( NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, eq_token: _, lit: Lit::Str(lstr) })) => Some(
// Convert the sigment of the path to a string // Convert the sigment of the path to a string
(path.segments (path.segments
.into_iter() .into_iter()

@ -4,14 +4,7 @@ pub mod requests;
pub mod responses; pub mod responses;
pub mod types; pub mod types;
use serde::{ use requests::Args;
Serialize,
Deserialize,
};
use requests::{
Args,
VMListRequest,
};
use clap::Parser; use clap::Parser;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {

@ -1,6 +1,5 @@
use crate::{ use crate::{
responses::{ responses::{
IPAddress,
VMListResponse, VMListResponse,
BillingCreditResponse, BillingCreditResponse,
LNImageListResponse, LNImageListResponse,
@ -38,17 +37,10 @@ use crate::{
}, },
}; };
use lunanode_macros::lunanode_request; use lunanode_macros::lunanode_request;
use parse_display_derive::Display;
use ureq::post;
use serde::{ use serde::{
Serialize, Serialize,
Serializer,
Deserialize, Deserialize,
de::DeserializeOwned,
}; };
use serde_with::serde_as;
use hmac::Hmac;
use sha2::Sha512;
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] #[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
pub enum SshKeySubArgs { pub enum SshKeySubArgs {

@ -1,19 +1,15 @@
use ureq;
use crate::success; use crate::success;
use crate::external; use crate::external;
use crate::types::{ use crate::types::{
LunaNodeResponse, LunaNodeResponse,
LunaNodeRequest,
}; };
use lunanode_macros::lunanode_response; use lunanode_macros::lunanode_response;
use serde_json;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use serde_with::{ use serde_with::{
DisplayFromStr, DisplayFromStr,
serde_as, serde_as,
}; };
use uuid;
#[serde_as] #[serde_as]
#[derive(Serialize, Deserialize, PartialEq, Debug)] #[derive(Serialize, Deserialize, PartialEq, Debug)]

@ -114,7 +114,7 @@ fn make_request<S, D>(req: &S) -> Result<D, LNError>
println!("RESP: {}", resp_str); println!("RESP: {}", resp_str);
match serde_json::from_str::<LNErrorResponse>(&resp_str) { match serde_json::from_str::<LNErrorResponse>(&resp_str) {
Ok(e) => return Err(LNError::LunaNodeError(e)), Ok(e) => return Err(LNError::LunaNodeError(e)),
Err(e) => false, Err(_e) => false,
}; };
match serde_json::from_str::<D>(&resp_str) { match serde_json::from_str::<D>(&resp_str) {
Ok(s) => Ok(s), Ok(s) => Ok(s),

Loading…
Cancel
Save