diff --git a/src/client.rs b/src/client.rs index ec24606..8eb73bb 100644 --- a/src/client.rs +++ b/src/client.rs @@ -21,8 +21,8 @@ impl Client { crate::core::Query::ChannelRequest(core) => { Query::ChannelRequest(ChannelRequest { client, core }) } - crate::core::Query::WithdrawalRequest(core) => { - Query::WithdrawalRequest(WithdrawalRequest { client, core }) + crate::core::Query::WithdrawRequest(core) => { + Query::WithdrawRequest(WithdrawRequest { client, core }) } }) } @@ -32,7 +32,7 @@ impl Client { pub enum Query<'a> { PayRequest(PayRequest<'a>), ChannelRequest(ChannelRequest<'a>), - WithdrawalRequest(WithdrawalRequest<'a>), + WithdrawRequest(WithdrawRequest<'a>), } #[derive(Clone, Debug)] @@ -48,9 +48,9 @@ pub struct ChannelRequest<'a> { } #[derive(Clone, Debug)] -pub struct WithdrawalRequest<'a> { +pub struct WithdrawRequest<'a> { client: &'a reqwest::Client, - pub core: crate::core::withdrawal_request::WithdrawalRequest, + pub core: crate::core::withdraw_request::WithdrawRequest, } impl PayRequest<'_> { @@ -109,7 +109,7 @@ impl ChannelRequest<'_> { } } -impl WithdrawalRequest<'_> { +impl WithdrawRequest<'_> { /// # Errors /// /// Returns errors on network or deserialization failures. diff --git a/src/core.rs b/src/core.rs index 5c299cf..abafa0f 100644 --- a/src/core.rs +++ b/src/core.rs @@ -1,6 +1,6 @@ pub mod channel_request; pub mod pay_request; -pub mod withdrawal_request; +pub mod withdraw_request; /// # Errors /// @@ -72,7 +72,7 @@ fn resolve_address(s: &str) -> Result { pub enum Query { PayRequest(pay_request::PayRequest), ChannelRequest(channel_request::ChannelRequest), - WithdrawalRequest(withdrawal_request::WithdrawalRequest), + WithdrawRequest(withdraw_request::WithdrawRequest), } impl std::str::FromStr for Query { @@ -89,9 +89,9 @@ impl std::str::FromStr for Query { if tag.tag == channel_request::TAG { let cr = s.parse().map_err(|_| "deserialize data failed")?; Ok(Query::ChannelRequest(cr)) - } else if tag.tag == withdrawal_request::TAG { + } else if tag.tag == withdraw_request::TAG { let wr = s.parse().map_err(|_| "deserialize data failed")?; - Ok(Query::WithdrawalRequest(wr)) + Ok(Query::WithdrawRequest(wr)) } else if tag.tag == pay_request::TAG { let pr = s.parse().map_err(|_| "deserialize data failed")?; Ok(Query::PayRequest(pr)) diff --git a/src/core/withdrawal_request.rs b/src/core/withdraw_request.rs similarity index 87% rename from src/core/withdrawal_request.rs rename to src/core/withdraw_request.rs index da1d392..6312856 100644 --- a/src/core/withdrawal_request.rs +++ b/src/core/withdraw_request.rs @@ -1,7 +1,7 @@ -pub const TAG: &str = "withdrawalRequest"; +pub const TAG: &str = "withdrawRequest"; #[derive(Clone, Debug)] -pub struct WithdrawalRequest { +pub struct WithdrawRequest { k1: String, callback: url::Url, pub description: String, @@ -9,14 +9,14 @@ pub struct WithdrawalRequest { pub max: u64, } -impl std::str::FromStr for WithdrawalRequest { +impl std::str::FromStr for WithdrawRequest { type Err = &'static str; fn from_str(s: &str) -> Result { let d: serde::QueryResponse = miniserde::json::from_str(s).map_err(|_| "deserialize failed")?; - Ok(WithdrawalRequest { + Ok(WithdrawRequest { k1: d.k1, callback: d.callback.0, description: d.default_description, @@ -26,7 +26,7 @@ impl std::str::FromStr for WithdrawalRequest { } } -impl WithdrawalRequest { +impl WithdrawRequest { /// # Errors /// /// Returns errors on network or deserialization failures. @@ -71,7 +71,7 @@ mod tests { } "#; - let parsed = input.parse::().expect("parse"); + let parsed = input.parse::().expect("parse"); assert_eq!(parsed.callback.to_string(), "https://yuri/?o=callback"); assert_eq!(parsed.description, "verde com bolinhas"); @@ -92,7 +92,7 @@ mod tests { } "#; - let parsed = input.parse::().expect("parse"); + let parsed = input.parse::().expect("parse"); assert_eq!( parsed.callback("pierre").to_string(),