From b13ab8de3ae21fd22d09dcfb3ac6a2999764b2ba Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 27 Jul 2022 14:33:48 +0200 Subject: [PATCH] msggen: Use owned versions to convert from cln-rpc to cln-grpc We needed to clone a lot since we were using a non-mutable borrow of the cln-rpc version to then create the cln-grpc version. This alone reduces the number of allocations of the `listpeers` test from 52 allocations to 38. --- cln-grpc/src/convert.rs | Bin 68785 -> 65567 bytes cln-grpc/src/pb.rs | 38 +++--- cln-grpc/src/server.rs | 184 +++++++++++++++--------------- cln-grpc/src/test.rs | 8 +- contrib/msggen/msggen/gen/grpc.py | 82 ++++++------- 5 files changed, 156 insertions(+), 156 deletions(-) diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index e5545c85cab7039d4c60aff336dc58349f0d676c..a8cfec26ee72f7cddeccab677489a5b9b7c626b6 100644 GIT binary patch delta 6261 zcmbtYdstM}7XOY83@|VbuYs8X93C<-z%U9bs4zf01bKs4rVy`i6k&KIT6Wc2Uuj(t z`Dvr3NqMzQQxwb0EX>sMMfOlDQ7J1QiCSqH7rlG$a|Q;l`t^1H*t7Q8XYaMw^S9QV zZ7W4<=ZjinIT*Ny$WUN4w+8Wp3UGRm0^0^@34I#HgXgg|gD43GkrHb~)yRli(4>%#UA75iXYf)>?c1zUed%&*@P*SO9sHU-TsuC1M` zCO9a-^jk zTR1Uf9HWu4A`E{v5dT;##<_o|V2HDfDOUK9H)@?TzzvdPtA{%bTA3hV9)I4YLb%Yc z+1&+8T%}B=4%cDWUYXqdfe3}KIXaf=N~aZ9Rh3s38OzZ1ycSK)BD2AslVY8lcmMej zf}S#zx~qwPA$Z4K#rO@Ddoh|L_YwB^-`AcBA|`KxNX++e7DS&f5**>zmhBljNZ=xE z+oW7Q*z$l`KGfa3sSo?mFyQAzYd77!{hEbLwIkLK^}&K94SpH=0;8MM|6=rU-$q9L z{q7eRS@_e>r_bk2{#s&I1-|re5abra6ySMZUAqJ1eR_fDg`8o&_uYJ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`X@xP zDL<^5GJZISpY20P=r(IfpCnGNVV|kEi#aGyPIZq!Ijs^UDyB)N@pMdoCP9<{EJ1;w zQ`70|>5VK=Eo)iD0}=4e^nL-xy(xCdv(KoP#T=-9%*n|B}&7G6 ze3vyvc3rae@~0QY;aIL-!zC4e{0wjMFs@7wikMs9BV%r}L?JV7NY}e-vCxbU8;TvP zl*=$lqZrqo_ly^|Jwc#^wyyS$*KU?LUOZ}a67H=`&XKg3GncryojMsF=Z8sUB5g;i zMlorwRmwyvV*sxw5J;D-bNctv*8q@6+^1(|^Y-x|H+v0whU>LU95P>CNT2CXx_*Qo zxkF396C;hlB<^{w?pO~Z)v4}5snaSEq0ZH!p)Ex7^dC+{<>t#C@$g&pjnD&?ILN2q z8W9#kwh<{Eo=BSJstv?tsql>sh18dv9R-(Yz;jeC?1rsRmAJrx(j!?NyEl6VeLTUd zxj1+np~{RNqaWJ=1L9x!9MM?~5j!v`f!Bp3*yW#jvwFBRt0ft zggU#V6_mtHxy{~im-<|59Gvv4XX0&=epPpchxgq$)jitBY4ype9wkLafLbFvSqWL% zNAIcO6jb|d;=Bn9c@~uPee$8bIe5RF*i|4>dQ7y{?7UkZcc-6!He%{Vb^r_RYN*_- zvh?N^I(-O%c1(`w)FfHL05>>B{F3}0gC1zoBU6EviE=f0-yteCh?q*31ld~W5?Skf zmny*=&Fq`!@+5WQPo2YqeUVmp2G8% zHzLEIxb6!X7kJX@=K8UN`&7~Wq|7)tlcWP9@$p-m{1!b_@f#)*XXc$v)5gv38xHcH SxU`s8^^H`2oG?VAfBz2|(K`bG diff --git a/cln-grpc/src/pb.rs b/cln-grpc/src/pb.rs index cfec44b65..00291d198 100644 --- a/cln-grpc/src/pb.rs +++ b/cln-grpc/src/pb.rs @@ -12,8 +12,8 @@ impl From for Amount { } } -impl From<&Amount> for JAmount { - fn from(a: &Amount) -> Self { +impl From for JAmount { + fn from(a: Amount) -> Self { JAmount::from_msat(a.msat) } } @@ -27,19 +27,19 @@ impl From for Outpoint { } } -impl From<&Outpoint> for JOutpoint { - fn from(a: &Outpoint) -> Self { +impl From for JOutpoint { + fn from(a: Outpoint) -> Self { JOutpoint { - txid: a.txid.clone(), + txid: a.txid, outnum: a.outnum, } } } -impl From<&Feerate> for cln_rpc::primitives::Feerate { - fn from(f: &Feerate) -> cln_rpc::primitives::Feerate { +impl From for cln_rpc::primitives::Feerate { + fn from(f: Feerate) -> cln_rpc::primitives::Feerate { use feerate::Style; - match f.style.clone().unwrap() { + match f.style.unwrap() { Style::Slow(_) => JFeerate::Slow, Style::Normal(_) => JFeerate::Normal, Style::Urgent(_) => JFeerate::Urgent, @@ -49,11 +49,11 @@ impl From<&Feerate> for cln_rpc::primitives::Feerate { } } -impl From<&OutputDesc> for JOutputDesc { - fn from(od: &OutputDesc) -> JOutputDesc { +impl From for JOutputDesc { + fn from(od: OutputDesc) -> JOutputDesc { JOutputDesc { - address: od.address.clone(), - amount: od.amount.as_ref().unwrap().into(), + address: od.address, + amount: od.amount.unwrap().into(), } } } @@ -71,9 +71,9 @@ impl From for AmountOrAll { } } -impl From<&AmountOrAll> for JAmountOrAll { - fn from(a: &AmountOrAll) -> Self { - match &a.value { +impl From for JAmountOrAll { + fn from(a: AmountOrAll) -> Self { + match a.value { Some(amount_or_all::Value::Amount(a)) => JAmountOrAll::Amount(a.into()), Some(amount_or_all::Value::All(_)) => JAmountOrAll::All, None => panic!("AmountOrAll is neither amount nor all: {:?}", a), @@ -93,9 +93,9 @@ impl From for AmountOrAny { } } } -impl From<&AmountOrAny> for JAmountOrAny { - fn from(a: &AmountOrAny) -> Self { - match &a.value { +impl From for JAmountOrAny { + fn from(a: AmountOrAny) -> Self { + match a.value { Some(amount_or_any::Value::Amount(a)) => JAmountOrAny::Amount(a.into()), Some(amount_or_any::Value::Any(_)) => JAmountOrAny::Any, None => panic!("AmountOrAll is neither amount nor any: {:?}", a), @@ -107,7 +107,7 @@ impl From for cln_rpc::primitives::Routehop { Self { id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), scid: cln_rpc::primitives::ShortChannelId::from_str(&c.short_channel_id).unwrap(), - feebase: c.feebase.as_ref().unwrap().into(), + feebase: c.feebase.unwrap().into(), feeprop: c.feeprop, expirydelta: c.expirydelta as u16, } diff --git a/cln-grpc/src/server.rs b/cln-grpc/src/server.rs index 16f75b561..22b6a5c09 100644 --- a/cln-grpc/src/server.rs +++ b/cln-grpc/src/server.rs @@ -31,7 +31,7 @@ async fn getinfo( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::GetinfoRequest = (&req).into(); + let req: requests::GetinfoRequest = req.into(); debug!("Client asked for getinfo"); trace!("getinfo request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -45,7 +45,7 @@ async fn getinfo( match result { Response::Getinfo(r) => { trace!("getinfo response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -63,7 +63,7 @@ async fn list_peers( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListpeersRequest = (&req).into(); + let req: requests::ListpeersRequest = req.into(); debug!("Client asked for list_peers"); trace!("list_peers request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -77,7 +77,7 @@ async fn list_peers( match result { Response::ListPeers(r) => { trace!("list_peers response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -95,7 +95,7 @@ async fn list_funds( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListfundsRequest = (&req).into(); + let req: requests::ListfundsRequest = req.into(); debug!("Client asked for list_funds"); trace!("list_funds request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -109,7 +109,7 @@ async fn list_funds( match result { Response::ListFunds(r) => { trace!("list_funds response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -127,7 +127,7 @@ async fn send_pay( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::SendpayRequest = (&req).into(); + let req: requests::SendpayRequest = req.into(); debug!("Client asked for send_pay"); trace!("send_pay request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -141,7 +141,7 @@ async fn send_pay( match result { Response::SendPay(r) => { trace!("send_pay response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -159,7 +159,7 @@ async fn list_channels( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListchannelsRequest = (&req).into(); + let req: requests::ListchannelsRequest = req.into(); debug!("Client asked for list_channels"); trace!("list_channels request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -173,7 +173,7 @@ async fn list_channels( match result { Response::ListChannels(r) => { trace!("list_channels response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -191,7 +191,7 @@ async fn add_gossip( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::AddgossipRequest = (&req).into(); + let req: requests::AddgossipRequest = req.into(); debug!("Client asked for add_gossip"); trace!("add_gossip request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -205,7 +205,7 @@ async fn add_gossip( match result { Response::AddGossip(r) => { trace!("add_gossip response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -223,7 +223,7 @@ async fn auto_clean_invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::AutocleaninvoiceRequest = (&req).into(); + let req: requests::AutocleaninvoiceRequest = req.into(); debug!("Client asked for auto_clean_invoice"); trace!("auto_clean_invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -237,7 +237,7 @@ async fn auto_clean_invoice( match result { Response::AutoCleanInvoice(r) => { trace!("auto_clean_invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -255,7 +255,7 @@ async fn check_message( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::CheckmessageRequest = (&req).into(); + let req: requests::CheckmessageRequest = req.into(); debug!("Client asked for check_message"); trace!("check_message request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -269,7 +269,7 @@ async fn check_message( match result { Response::CheckMessage(r) => { trace!("check_message response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -287,7 +287,7 @@ async fn close( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::CloseRequest = (&req).into(); + let req: requests::CloseRequest = req.into(); debug!("Client asked for close"); trace!("close request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -301,7 +301,7 @@ async fn close( match result { Response::Close(r) => { trace!("close response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -319,7 +319,7 @@ async fn connect_peer( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ConnectRequest = (&req).into(); + let req: requests::ConnectRequest = req.into(); debug!("Client asked for connect_peer"); trace!("connect_peer request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -333,7 +333,7 @@ async fn connect_peer( match result { Response::Connect(r) => { trace!("connect_peer response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -351,7 +351,7 @@ async fn create_invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::CreateinvoiceRequest = (&req).into(); + let req: requests::CreateinvoiceRequest = req.into(); debug!("Client asked for create_invoice"); trace!("create_invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -365,7 +365,7 @@ async fn create_invoice( match result { Response::CreateInvoice(r) => { trace!("create_invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -383,7 +383,7 @@ async fn datastore( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::DatastoreRequest = (&req).into(); + let req: requests::DatastoreRequest = req.into(); debug!("Client asked for datastore"); trace!("datastore request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -397,7 +397,7 @@ async fn datastore( match result { Response::Datastore(r) => { trace!("datastore response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -415,7 +415,7 @@ async fn create_onion( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::CreateonionRequest = (&req).into(); + let req: requests::CreateonionRequest = req.into(); debug!("Client asked for create_onion"); trace!("create_onion request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -429,7 +429,7 @@ async fn create_onion( match result { Response::CreateOnion(r) => { trace!("create_onion response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -447,7 +447,7 @@ async fn del_datastore( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::DeldatastoreRequest = (&req).into(); + let req: requests::DeldatastoreRequest = req.into(); debug!("Client asked for del_datastore"); trace!("del_datastore request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -461,7 +461,7 @@ async fn del_datastore( match result { Response::DelDatastore(r) => { trace!("del_datastore response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -479,7 +479,7 @@ async fn del_expired_invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::DelexpiredinvoiceRequest = (&req).into(); + let req: requests::DelexpiredinvoiceRequest = req.into(); debug!("Client asked for del_expired_invoice"); trace!("del_expired_invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -493,7 +493,7 @@ async fn del_expired_invoice( match result { Response::DelExpiredInvoice(r) => { trace!("del_expired_invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -511,7 +511,7 @@ async fn del_invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::DelinvoiceRequest = (&req).into(); + let req: requests::DelinvoiceRequest = req.into(); debug!("Client asked for del_invoice"); trace!("del_invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -525,7 +525,7 @@ async fn del_invoice( match result { Response::DelInvoice(r) => { trace!("del_invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -543,7 +543,7 @@ async fn invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::InvoiceRequest = (&req).into(); + let req: requests::InvoiceRequest = req.into(); debug!("Client asked for invoice"); trace!("invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -557,7 +557,7 @@ async fn invoice( match result { Response::Invoice(r) => { trace!("invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -575,7 +575,7 @@ async fn list_datastore( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListdatastoreRequest = (&req).into(); + let req: requests::ListdatastoreRequest = req.into(); debug!("Client asked for list_datastore"); trace!("list_datastore request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -589,7 +589,7 @@ async fn list_datastore( match result { Response::ListDatastore(r) => { trace!("list_datastore response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -607,7 +607,7 @@ async fn list_invoices( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListinvoicesRequest = (&req).into(); + let req: requests::ListinvoicesRequest = req.into(); debug!("Client asked for list_invoices"); trace!("list_invoices request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -621,7 +621,7 @@ async fn list_invoices( match result { Response::ListInvoices(r) => { trace!("list_invoices response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -639,7 +639,7 @@ async fn send_onion( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::SendonionRequest = (&req).into(); + let req: requests::SendonionRequest = req.into(); debug!("Client asked for send_onion"); trace!("send_onion request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -653,7 +653,7 @@ async fn send_onion( match result { Response::SendOnion(r) => { trace!("send_onion response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -671,7 +671,7 @@ async fn list_send_pays( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListsendpaysRequest = (&req).into(); + let req: requests::ListsendpaysRequest = req.into(); debug!("Client asked for list_send_pays"); trace!("list_send_pays request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -685,7 +685,7 @@ async fn list_send_pays( match result { Response::ListSendPays(r) => { trace!("list_send_pays response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -703,7 +703,7 @@ async fn list_transactions( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListtransactionsRequest = (&req).into(); + let req: requests::ListtransactionsRequest = req.into(); debug!("Client asked for list_transactions"); trace!("list_transactions request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -717,7 +717,7 @@ async fn list_transactions( match result { Response::ListTransactions(r) => { trace!("list_transactions response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -735,7 +735,7 @@ async fn pay( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::PayRequest = (&req).into(); + let req: requests::PayRequest = req.into(); debug!("Client asked for pay"); trace!("pay request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -749,7 +749,7 @@ async fn pay( match result { Response::Pay(r) => { trace!("pay response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -767,7 +767,7 @@ async fn list_nodes( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListnodesRequest = (&req).into(); + let req: requests::ListnodesRequest = req.into(); debug!("Client asked for list_nodes"); trace!("list_nodes request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -781,7 +781,7 @@ async fn list_nodes( match result { Response::ListNodes(r) => { trace!("list_nodes response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -799,7 +799,7 @@ async fn wait_any_invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::WaitanyinvoiceRequest = (&req).into(); + let req: requests::WaitanyinvoiceRequest = req.into(); debug!("Client asked for wait_any_invoice"); trace!("wait_any_invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -813,7 +813,7 @@ async fn wait_any_invoice( match result { Response::WaitAnyInvoice(r) => { trace!("wait_any_invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -831,7 +831,7 @@ async fn wait_invoice( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::WaitinvoiceRequest = (&req).into(); + let req: requests::WaitinvoiceRequest = req.into(); debug!("Client asked for wait_invoice"); trace!("wait_invoice request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -845,7 +845,7 @@ async fn wait_invoice( match result { Response::WaitInvoice(r) => { trace!("wait_invoice response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -863,7 +863,7 @@ async fn wait_send_pay( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::WaitsendpayRequest = (&req).into(); + let req: requests::WaitsendpayRequest = req.into(); debug!("Client asked for wait_send_pay"); trace!("wait_send_pay request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -877,7 +877,7 @@ async fn wait_send_pay( match result { Response::WaitSendPay(r) => { trace!("wait_send_pay response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -895,7 +895,7 @@ async fn new_addr( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::NewaddrRequest = (&req).into(); + let req: requests::NewaddrRequest = req.into(); debug!("Client asked for new_addr"); trace!("new_addr request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -909,7 +909,7 @@ async fn new_addr( match result { Response::NewAddr(r) => { trace!("new_addr response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -927,7 +927,7 @@ async fn withdraw( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::WithdrawRequest = (&req).into(); + let req: requests::WithdrawRequest = req.into(); debug!("Client asked for withdraw"); trace!("withdraw request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -941,7 +941,7 @@ async fn withdraw( match result { Response::Withdraw(r) => { trace!("withdraw response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -959,7 +959,7 @@ async fn key_send( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::KeysendRequest = (&req).into(); + let req: requests::KeysendRequest = req.into(); debug!("Client asked for key_send"); trace!("key_send request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -973,7 +973,7 @@ async fn key_send( match result { Response::KeySend(r) => { trace!("key_send response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -991,7 +991,7 @@ async fn fund_psbt( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::FundpsbtRequest = (&req).into(); + let req: requests::FundpsbtRequest = req.into(); debug!("Client asked for fund_psbt"); trace!("fund_psbt request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1005,7 +1005,7 @@ async fn fund_psbt( match result { Response::FundPsbt(r) => { trace!("fund_psbt response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1023,7 +1023,7 @@ async fn send_psbt( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::SendpsbtRequest = (&req).into(); + let req: requests::SendpsbtRequest = req.into(); debug!("Client asked for send_psbt"); trace!("send_psbt request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1037,7 +1037,7 @@ async fn send_psbt( match result { Response::SendPsbt(r) => { trace!("send_psbt response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1055,7 +1055,7 @@ async fn sign_psbt( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::SignpsbtRequest = (&req).into(); + let req: requests::SignpsbtRequest = req.into(); debug!("Client asked for sign_psbt"); trace!("sign_psbt request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1069,7 +1069,7 @@ async fn sign_psbt( match result { Response::SignPsbt(r) => { trace!("sign_psbt response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1087,7 +1087,7 @@ async fn utxo_psbt( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::UtxopsbtRequest = (&req).into(); + let req: requests::UtxopsbtRequest = req.into(); debug!("Client asked for utxo_psbt"); trace!("utxo_psbt request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1101,7 +1101,7 @@ async fn utxo_psbt( match result { Response::UtxoPsbt(r) => { trace!("utxo_psbt response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1119,7 +1119,7 @@ async fn tx_discard( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::TxdiscardRequest = (&req).into(); + let req: requests::TxdiscardRequest = req.into(); debug!("Client asked for tx_discard"); trace!("tx_discard request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1133,7 +1133,7 @@ async fn tx_discard( match result { Response::TxDiscard(r) => { trace!("tx_discard response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1151,7 +1151,7 @@ async fn tx_prepare( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::TxprepareRequest = (&req).into(); + let req: requests::TxprepareRequest = req.into(); debug!("Client asked for tx_prepare"); trace!("tx_prepare request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1165,7 +1165,7 @@ async fn tx_prepare( match result { Response::TxPrepare(r) => { trace!("tx_prepare response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1183,7 +1183,7 @@ async fn tx_send( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::TxsendRequest = (&req).into(); + let req: requests::TxsendRequest = req.into(); debug!("Client asked for tx_send"); trace!("tx_send request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1197,7 +1197,7 @@ async fn tx_send( match result { Response::TxSend(r) => { trace!("tx_send response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1215,7 +1215,7 @@ async fn disconnect( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::DisconnectRequest = (&req).into(); + let req: requests::DisconnectRequest = req.into(); debug!("Client asked for disconnect"); trace!("disconnect request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1229,7 +1229,7 @@ async fn disconnect( match result { Response::Disconnect(r) => { trace!("disconnect response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1247,7 +1247,7 @@ async fn feerates( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::FeeratesRequest = (&req).into(); + let req: requests::FeeratesRequest = req.into(); debug!("Client asked for feerates"); trace!("feerates request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1261,7 +1261,7 @@ async fn feerates( match result { Response::Feerates(r) => { trace!("feerates response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1279,7 +1279,7 @@ async fn fund_channel( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::FundchannelRequest = (&req).into(); + let req: requests::FundchannelRequest = req.into(); debug!("Client asked for fund_channel"); trace!("fund_channel request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1293,7 +1293,7 @@ async fn fund_channel( match result { Response::FundChannel(r) => { trace!("fund_channel response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1311,7 +1311,7 @@ async fn get_route( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::GetrouteRequest = (&req).into(); + let req: requests::GetrouteRequest = req.into(); debug!("Client asked for get_route"); trace!("get_route request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1325,7 +1325,7 @@ async fn get_route( match result { Response::GetRoute(r) => { trace!("get_route response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1343,7 +1343,7 @@ async fn list_forwards( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListforwardsRequest = (&req).into(); + let req: requests::ListforwardsRequest = req.into(); debug!("Client asked for list_forwards"); trace!("list_forwards request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1357,7 +1357,7 @@ async fn list_forwards( match result { Response::ListForwards(r) => { trace!("list_forwards response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1375,7 +1375,7 @@ async fn list_pays( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::ListpaysRequest = (&req).into(); + let req: requests::ListpaysRequest = req.into(); debug!("Client asked for list_pays"); trace!("list_pays request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1389,7 +1389,7 @@ async fn list_pays( match result { Response::ListPays(r) => { trace!("list_pays response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1407,7 +1407,7 @@ async fn ping( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::PingRequest = (&req).into(); + let req: requests::PingRequest = req.into(); debug!("Client asked for ping"); trace!("ping request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1421,7 +1421,7 @@ async fn ping( match result { Response::Ping(r) => { trace!("ping response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1439,7 +1439,7 @@ async fn sign_message( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::SignmessageRequest = (&req).into(); + let req: requests::SignmessageRequest = req.into(); debug!("Client asked for sign_message"); trace!("sign_message request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1453,7 +1453,7 @@ async fn sign_message( match result { Response::SignMessage(r) => { trace!("sign_message response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, @@ -1471,7 +1471,7 @@ async fn stop( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::StopRequest = (&req).into(); + let req: requests::StopRequest = req.into(); debug!("Client asked for stop"); trace!("stop request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1485,7 +1485,7 @@ async fn stop( match result { Response::Stop(r) => { trace!("stop response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, diff --git a/cln-grpc/src/test.rs b/cln-grpc/src/test.rs index 78f49cdc5..1a600dee6 100644 --- a/cln-grpc/src/test.rs +++ b/cln-grpc/src/test.rs @@ -215,7 +215,7 @@ fn test_listpeers() { ] }); let u: cln_rpc::model::ListpeersResponse = serde_json::from_value(j).unwrap(); - let _: ListpeersResponse = (&u).into(); + let _: ListpeersResponse = u.into(); } #[test] @@ -237,7 +237,7 @@ fn test_getinfo() { "fees_collected_msat": "0msat", "lightning-dir": "/tmp/ltests-20irp76f/test_pay_variants_1/lightning-1/regtest", "our_features": {"init": "8808226aa2", "node": "80008808226aa2", "channel": "", "invoice": "024200"}}); let u: cln_rpc::model::GetinfoResponse = serde_json::from_value(j).unwrap(); - let _g: GetinfoResponse = (&u).into(); + let _g: GetinfoResponse = u.into(); } #[test] @@ -280,7 +280,7 @@ fn test_keysend() { }), }; - let u: cln_rpc::model::KeysendRequest = (&g).into(); + let u: cln_rpc::model::KeysendRequest = g.into(); let _ser = serde_json::to_string(&u); let j = r#"{ @@ -296,6 +296,6 @@ fn test_keysend() { "status": "complete" }"#; let u: cln_rpc::model::KeysendResponse = serde_json::from_str(j).unwrap(); - let g: KeysendResponse = (&u).into(); + let g: KeysendResponse = u.into(); println!("{:?}", g); } diff --git a/contrib/msggen/msggen/gen/grpc.py b/contrib/msggen/msggen/gen/grpc.py index 9f5c963ba..074b435ce 100644 --- a/contrib/msggen/msggen/gen/grpc.py +++ b/contrib/msggen/msggen/gen/grpc.py @@ -260,8 +260,8 @@ class GrpcConverterGenerator(IGenerator): # And now we can convert the current field: self.write(f"""\ #[allow(unused_variables)] - impl From<&{prefix}::{field.typename}> for pb::{field.typename} {{ - fn from(c: &{prefix}::{field.typename}) -> Self {{ + impl From<{prefix}::{field.typename}> for pb::{field.typename} {{ + fn from(c: {prefix}::{field.typename}) -> Self {{ Self {{ """) @@ -277,13 +277,13 @@ class GrpcConverterGenerator(IGenerator): # array. The current item is called `i` mapping = { 'hex': f'hex::decode(i).unwrap()', - 'secret': f'i.clone().to_vec()', + 'secret': f'i.to_vec()', }.get(typ, f'i.into()') if f.required: - self.write(f"{name}: c.{name}.iter().map(|i| {mapping}).collect(), // Rule #3 for type {typ} \n", numindent=3) + self.write(f"{name}: c.{name}.into_iter().map(|i| {mapping}).collect(), // Rule #3 for type {typ} \n", numindent=3) else: - self.write(f"{name}: c.{name}.as_ref().map(|arr| arr.iter().map(|i| {mapping}).collect()).unwrap_or(vec![]), // Rule #3 \n", numindent=3) + self.write(f"{name}: c.{name}.map(|arr| arr.into_iter().map(|i| {mapping}).collect()).unwrap_or(vec![]), // Rule #3 \n", numindent=3) elif isinstance(f, EnumField): if f.required: self.write(f"{name}: c.{name} as i32,\n", numindent=3) @@ -303,20 +303,20 @@ class GrpcConverterGenerator(IGenerator): 'msat': f'Some(c.{name}.into())', 'msat?': f'c.{name}.map(|f| f.into())', 'pubkey': f'c.{name}.to_vec()', - 'pubkey?': f'c.{name}.as_ref().map(|v| v.to_vec())', + 'pubkey?': f'c.{name}.map(|v| v.to_vec())', 'hex': f'hex::decode(&c.{name}).unwrap()', - 'hex?': f'c.{name}.as_ref().map(|v| hex::decode(&v).unwrap())', + 'hex?': f'c.{name}.map(|v| hex::decode(v).unwrap())', 'txid': f'hex::decode(&c.{name}).unwrap()', - 'txid?': f'c.{name}.as_ref().map(|v| hex::decode(&v).unwrap())', + 'txid?': f'c.{name}.map(|v| hex::decode(v).unwrap())', 'short_channel_id': f'c.{name}.to_string()', - 'short_channel_id?': f'c.{name}.as_ref().map(|v| v.to_string())', - 'hash': f'c.{name}.clone().to_vec()', - 'hash?': f'c.{name}.clone().map(|v| v.to_vec())', - 'secret': f'c.{name}.clone().to_vec()', - 'secret?': f'c.{name}.clone().map(|v| v.to_vec())', + 'short_channel_id?': f'c.{name}.map(|v| v.to_string())', + 'hash': f'c.{name}.to_vec()', + 'hash?': f'c.{name}.map(|v| v.to_vec())', + 'secret': f'c.{name}.to_vec()', + 'secret?': f'c.{name}.map(|v| v.to_vec())', }.get( typ, - f'c.{name}.clone()' # default to just assignment + f'c.{name}' # default to just assignment ) self.write(f"{name}: {rhs}, // Rule #2 for type {typ}\n", numindent=3) @@ -381,8 +381,8 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator): # And now we can convert the current field: self.write(f"""\ #[allow(unused_variables)] - impl From<&pb::{field.typename}> for {prefix}::{field.typename} {{ - fn from(c: &pb::{field.typename}) -> Self {{ + impl From for {prefix}::{field.typename} {{ + fn from(c: pb::{field.typename}) -> Self {{ Self {{ """) @@ -392,13 +392,13 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator): typ = f.itemtype.typename mapping = { 'hex': f'hex::encode(s)', - 'u32': f's.clone()', - 'secret': f's.clone().try_into().unwrap()' + 'u32': f's', + 'secret': f's.try_into().unwrap()' }.get(typ, f's.into()') if f.required: - self.write(f"{name}: c.{name}.iter().map(|s| {mapping}).collect(), // Rule #4\n", numindent=3) + self.write(f"{name}: c.{name}.into_iter().map(|s| {mapping}).collect(), // Rule #4\n", numindent=3) else: - self.write(f"{name}: Some(c.{name}.iter().map(|s| {mapping}).collect()), // Rule #4\n", numindent=3) + self.write(f"{name}: Some(c.{name}.into_iter().map(|s| {mapping}).collect()), // Rule #4\n", numindent=3) elif isinstance(f, EnumField): if f.required: @@ -416,30 +416,30 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator): 'u16': f'c.{name} as u16', 'u16?': f'c.{name}.map(|v| v as u16)', 'hex': f'hex::encode(&c.{name})', - 'hex?': f'c.{name}.clone().map(|v| hex::encode(v))', - 'txid?': f'c.{name}.clone().map(|v| hex::encode(v))', + 'hex?': f'c.{name}.map(|v| hex::encode(v))', + 'txid?': f'c.{name}.map(|v| hex::encode(v))', 'pubkey': f'cln_rpc::primitives::Pubkey::from_slice(&c.{name}).unwrap()', - 'pubkey?': f'c.{name}.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap())', - 'msat': f'c.{name}.as_ref().unwrap().into()', - 'msat?': f'c.{name}.as_ref().map(|a| a.into())', - 'msat_or_all': f'c.{name}.as_ref().unwrap().into()', - 'msat_or_all?': f'c.{name}.as_ref().map(|a| a.into())', - 'msat_or_any': f'c.{name}.as_ref().unwrap().into()', - 'msat_or_any?': f'c.{name}.as_ref().map(|a| a.into())', - 'feerate': f'c.{name}.as_ref().unwrap().into()', - 'feerate?': f'c.{name}.as_ref().map(|a| a.into())', - 'outpoint?': f'c.{name}.as_ref().map(|a| a.into())', - 'RoutehintList?': f'c.{name}.clone().map(|rl| rl.into())', + 'pubkey?': f'c.{name}.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap())', + 'msat': f'c.{name}.unwrap().into()', + 'msat?': f'c.{name}.map(|a| a.into())', + 'msat_or_all': f'c.{name}.unwrap().into()', + 'msat_or_all?': f'c.{name}.map(|a| a.into())', + 'msat_or_any': f'c.{name}.unwrap().into()', + 'msat_or_any?': f'c.{name}.map(|a| a.into())', + 'feerate': f'c.{name}.unwrap().into()', + 'feerate?': f'c.{name}.map(|a| a.into())', + 'outpoint?': f'c.{name}.map(|a| a.into())', + 'RoutehintList?': f'c.{name}.map(|rl| rl.into())', 'short_channel_id': f'cln_rpc::primitives::ShortChannelId::from_str(&c.{name}).unwrap()', - 'short_channel_id?': f'c.{name}.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap())', - 'secret': f'c.{name}.clone().try_into().unwrap()', - 'secret?': f'c.{name}.clone().map(|v| v.try_into().unwrap())', - 'hash': f'c.{name}.clone().try_into().unwrap()', - 'hash?': f'c.{name}.clone().map(|v| v.try_into().unwrap())', + 'short_channel_id?': f'c.{name}.map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap())', + 'secret': f'c.{name}.try_into().unwrap()', + 'secret?': f'c.{name}.map(|v| v.try_into().unwrap())', + 'hash': f'c.{name}.try_into().unwrap()', + 'hash?': f'c.{name}.map(|v| v.try_into().unwrap())', 'txid': f'hex::encode(&c.{name})', }.get( typ, - f'c.{name}.clone()' # default to just assignment + f'c.{name}' # default to just assignment ) self.write(f"{name}: {rhs}, // Rule #1 for type {typ}\n", numindent=3) @@ -494,7 +494,7 @@ class GrpcServerGenerator(GrpcConverterGenerator): request: tonic::Request, ) -> Result, tonic::Status> {{ let req = request.into_inner(); - let req: requests::{method.request.typename} = (&req).into(); + let req: requests::{method.request.typename} = req.into(); debug!("Client asked for {name}"); trace!("{name} request: {{:?}}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -508,7 +508,7 @@ class GrpcServerGenerator(GrpcConverterGenerator): match result {{ Response::{method.name}(r) => {{ trace!("{name} response: {{:?}}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }}, r => Err(Status::new( Code::Internal,