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 | 1322 ++++++++++++++--------------- 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, 817 insertions(+), 817 deletions(-) diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index e5545c85c..a8cfec26e 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -10,74 +10,74 @@ use crate::pb; use std::str::FromStr; #[allow(unused_variables)] -impl From<&responses::GetinfoAddress> for pb::GetinfoAddress { - fn from(c: &responses::GetinfoAddress) -> Self { +impl From for pb::GetinfoAddress { + fn from(c: responses::GetinfoAddress) -> Self { Self { item_type: c.item_type as i32, port: c.port.into(), // Rule #2 for type u16 - address: c.address.clone(), // Rule #2 for type string? + address: c.address, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::GetinfoBinding> for pb::GetinfoBinding { - fn from(c: &responses::GetinfoBinding) -> Self { +impl From for pb::GetinfoBinding { + fn from(c: responses::GetinfoBinding) -> Self { Self { item_type: c.item_type as i32, - address: c.address.clone(), // Rule #2 for type string? + address: c.address, // Rule #2 for type string? port: c.port.map(|v| v.into()), // Rule #2 for type u16? - socket: c.socket.clone(), // Rule #2 for type string? + socket: c.socket, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::GetinfoResponse> for pb::GetinfoResponse { - fn from(c: &responses::GetinfoResponse) -> Self { +impl From for pb::GetinfoResponse { + fn from(c: responses::GetinfoResponse) -> Self { Self { id: c.id.to_vec(), // Rule #2 for type pubkey - alias: c.alias.clone(), // Rule #2 for type string + alias: c.alias, // Rule #2 for type string color: hex::decode(&c.color).unwrap(), // Rule #2 for type hex - num_peers: c.num_peers.clone(), // Rule #2 for type u32 - num_pending_channels: c.num_pending_channels.clone(), // Rule #2 for type u32 - num_active_channels: c.num_active_channels.clone(), // Rule #2 for type u32 - num_inactive_channels: c.num_inactive_channels.clone(), // Rule #2 for type u32 - version: c.version.clone(), // Rule #2 for type string - lightning_dir: c.lightning_dir.clone(), // Rule #2 for type string - blockheight: c.blockheight.clone(), // Rule #2 for type u32 - network: c.network.clone(), // Rule #2 for type string + num_peers: c.num_peers, // Rule #2 for type u32 + num_pending_channels: c.num_pending_channels, // Rule #2 for type u32 + num_active_channels: c.num_active_channels, // Rule #2 for type u32 + num_inactive_channels: c.num_inactive_channels, // Rule #2 for type u32 + version: c.version, // Rule #2 for type string + lightning_dir: c.lightning_dir, // Rule #2 for type string + blockheight: c.blockheight, // Rule #2 for type u32 + network: c.network, // Rule #2 for type string fees_collected_msat: Some(c.fees_collected_msat.into()), // Rule #2 for type msat - address: c.address.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - binding: c.binding.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - warning_bitcoind_sync: c.warning_bitcoind_sync.clone(), // Rule #2 for type string? - warning_lightningd_sync: c.warning_lightningd_sync.clone(), // Rule #2 for type string? + address: c.address.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + binding: c.binding.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + warning_bitcoind_sync: c.warning_bitcoind_sync, // Rule #2 for type string? + warning_lightningd_sync: c.warning_lightningd_sync, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListpeersPeersLog> for pb::ListpeersPeersLog { - fn from(c: &responses::ListpeersPeersLog) -> Self { +impl From for pb::ListpeersPeersLog { + fn from(c: responses::ListpeersPeersLog) -> Self { Self { item_type: c.item_type as i32, - num_skipped: c.num_skipped.clone(), // Rule #2 for type u32? - time: c.time.clone(), // Rule #2 for type string? - source: c.source.clone(), // Rule #2 for type string? - log: c.log.clone(), // Rule #2 for type string? - node_id: c.node_id.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - data: c.data.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + num_skipped: c.num_skipped, // Rule #2 for type u32? + time: c.time, // Rule #2 for type string? + source: c.source, // Rule #2 for type string? + log: c.log, // Rule #2 for type string? + node_id: c.node_id.map(|v| v.to_vec()), // Rule #2 for type pubkey? + data: c.data.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? } } } #[allow(unused_variables)] -impl From<&responses::ListpeersPeersChannelsInflight> for pb::ListpeersPeersChannelsInflight { - fn from(c: &responses::ListpeersPeersChannelsInflight) -> Self { +impl From for pb::ListpeersPeersChannelsInflight { + fn from(c: responses::ListpeersPeersChannelsInflight) -> Self { Self { funding_txid: hex::decode(&c.funding_txid).unwrap(), // Rule #2 for type txid - funding_outnum: c.funding_outnum.clone(), // Rule #2 for type u32 - feerate: c.feerate.clone(), // Rule #2 for type string + funding_outnum: c.funding_outnum, // Rule #2 for type u32 + feerate: c.feerate, // Rule #2 for type string total_funding_msat: Some(c.total_funding_msat.into()), // Rule #2 for type msat our_funding_msat: Some(c.our_funding_msat.into()), // Rule #2 for type msat scratch_txid: hex::decode(&c.scratch_txid).unwrap(), // Rule #2 for type txid @@ -86,47 +86,47 @@ impl From<&responses::ListpeersPeersChannelsInflight> for pb::ListpeersPeersChan } #[allow(unused_variables)] -impl From<&responses::ListpeersPeersChannelsHtlcs> for pb::ListpeersPeersChannelsHtlcs { - fn from(c: &responses::ListpeersPeersChannelsHtlcs) -> Self { +impl From for pb::ListpeersPeersChannelsHtlcs { + fn from(c: responses::ListpeersPeersChannelsHtlcs) -> Self { Self { direction: c.direction as i32, - id: c.id.clone(), // Rule #2 for type u64 + id: c.id, // Rule #2 for type u64 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat - expiry: c.expiry.clone(), // Rule #2 for type u32 - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash - local_trimmed: c.local_trimmed.clone(), // Rule #2 for type boolean? - status: c.status.clone(), // Rule #2 for type string? + expiry: c.expiry, // Rule #2 for type u32 + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash + local_trimmed: c.local_trimmed, // Rule #2 for type boolean? + status: c.status, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListpeersPeersChannels> for pb::ListpeersPeersChannels { - fn from(c: &responses::ListpeersPeersChannels) -> Self { +impl From for pb::ListpeersPeersChannels { + fn from(c: responses::ListpeersPeersChannels) -> Self { Self { state: c.state as i32, - scratch_txid: c.scratch_txid.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type txid? - owner: c.owner.clone(), // Rule #2 for type string? - short_channel_id: c.short_channel_id.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? - channel_id: c.channel_id.clone().map(|v| v.to_vec()), // Rule #2 for type hash? - funding_txid: c.funding_txid.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type txid? - funding_outnum: c.funding_outnum.clone(), // Rule #2 for type u32? - initial_feerate: c.initial_feerate.clone(), // Rule #2 for type string? - last_feerate: c.last_feerate.clone(), // Rule #2 for type string? - next_feerate: c.next_feerate.clone(), // Rule #2 for type string? - next_fee_step: c.next_fee_step.clone(), // Rule #2 for type u32? - inflight: c.inflight.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - close_to: c.close_to.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - private: c.private.clone(), // Rule #2 for type boolean? + scratch_txid: c.scratch_txid.map(|v| hex::decode(v).unwrap()), // Rule #2 for type txid? + owner: c.owner, // Rule #2 for type string? + short_channel_id: c.short_channel_id.map(|v| v.to_string()), // Rule #2 for type short_channel_id? + channel_id: c.channel_id.map(|v| v.to_vec()), // Rule #2 for type hash? + funding_txid: c.funding_txid.map(|v| hex::decode(v).unwrap()), // Rule #2 for type txid? + funding_outnum: c.funding_outnum, // Rule #2 for type u32? + initial_feerate: c.initial_feerate, // Rule #2 for type string? + last_feerate: c.last_feerate, // Rule #2 for type string? + next_feerate: c.next_feerate, // Rule #2 for type string? + next_fee_step: c.next_fee_step, // Rule #2 for type u32? + inflight: c.inflight.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + close_to: c.close_to.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + private: c.private, // Rule #2 for type boolean? opener: c.opener as i32, closer: c.closer.map(|v| v as i32), - features: c.features.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannelsFeatures + features: c.features.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannelsFeatures to_us_msat: c.to_us_msat.map(|f| f.into()), // Rule #2 for type msat? min_to_us_msat: c.min_to_us_msat.map(|f| f.into()), // Rule #2 for type msat? max_to_us_msat: c.max_to_us_msat.map(|f| f.into()), // Rule #2 for type msat? total_msat: c.total_msat.map(|f| f.into()), // Rule #2 for type msat? fee_base_msat: c.fee_base_msat.map(|f| f.into()), // Rule #2 for type msat? - fee_proportional_millionths: c.fee_proportional_millionths.clone(), // Rule #2 for type u32? + fee_proportional_millionths: c.fee_proportional_millionths, // Rule #2 for type u32? dust_limit_msat: c.dust_limit_msat.map(|f| f.into()), // Rule #2 for type msat? max_total_htlc_in_msat: c.max_total_htlc_in_msat.map(|f| f.into()), // Rule #2 for type msat? their_reserve_msat: c.their_reserve_msat.map(|f| f.into()), // Rule #2 for type msat? @@ -136,130 +136,130 @@ impl From<&responses::ListpeersPeersChannels> for pb::ListpeersPeersChannels { minimum_htlc_in_msat: c.minimum_htlc_in_msat.map(|f| f.into()), // Rule #2 for type msat? minimum_htlc_out_msat: c.minimum_htlc_out_msat.map(|f| f.into()), // Rule #2 for type msat? maximum_htlc_out_msat: c.maximum_htlc_out_msat.map(|f| f.into()), // Rule #2 for type msat? - their_to_self_delay: c.their_to_self_delay.clone(), // Rule #2 for type u32? - our_to_self_delay: c.our_to_self_delay.clone(), // Rule #2 for type u32? - max_accepted_htlcs: c.max_accepted_htlcs.clone(), // Rule #2 for type u32? - status: c.status.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - in_payments_offered: c.in_payments_offered.clone(), // Rule #2 for type u64? + their_to_self_delay: c.their_to_self_delay, // Rule #2 for type u32? + our_to_self_delay: c.our_to_self_delay, // Rule #2 for type u32? + max_accepted_htlcs: c.max_accepted_htlcs, // Rule #2 for type u32? + status: c.status.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + in_payments_offered: c.in_payments_offered, // Rule #2 for type u64? in_offered_msat: c.in_offered_msat.map(|f| f.into()), // Rule #2 for type msat? - in_payments_fulfilled: c.in_payments_fulfilled.clone(), // Rule #2 for type u64? + in_payments_fulfilled: c.in_payments_fulfilled, // Rule #2 for type u64? in_fulfilled_msat: c.in_fulfilled_msat.map(|f| f.into()), // Rule #2 for type msat? - out_payments_offered: c.out_payments_offered.clone(), // Rule #2 for type u64? + out_payments_offered: c.out_payments_offered, // Rule #2 for type u64? out_offered_msat: c.out_offered_msat.map(|f| f.into()), // Rule #2 for type msat? - out_payments_fulfilled: c.out_payments_fulfilled.clone(), // Rule #2 for type u64? + out_payments_fulfilled: c.out_payments_fulfilled, // Rule #2 for type u64? out_fulfilled_msat: c.out_fulfilled_msat.map(|f| f.into()), // Rule #2 for type msat? - htlcs: c.htlcs.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - close_to_addr: c.close_to_addr.clone(), // Rule #2 for type string? + htlcs: c.htlcs.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + close_to_addr: c.close_to_addr, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListpeersPeers> for pb::ListpeersPeers { - fn from(c: &responses::ListpeersPeers) -> Self { +impl From for pb::ListpeersPeers { + fn from(c: responses::ListpeersPeers) -> Self { Self { id: c.id.to_vec(), // Rule #2 for type pubkey - connected: c.connected.clone(), // Rule #2 for type boolean - log: c.log.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannels - netaddr: c.netaddr.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - remote_addr: c.remote_addr.clone(), // Rule #2 for type string? - features: c.features.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + connected: c.connected, // Rule #2 for type boolean + log: c.log.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + channels: c.channels.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannels + netaddr: c.netaddr.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + remote_addr: c.remote_addr, // Rule #2 for type string? + features: c.features.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? } } } #[allow(unused_variables)] -impl From<&responses::ListpeersResponse> for pb::ListpeersResponse { - fn from(c: &responses::ListpeersResponse) -> Self { +impl From for pb::ListpeersResponse { + fn from(c: responses::ListpeersResponse) -> Self { Self { - peers: c.peers.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeers + peers: c.peers.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeers } } } #[allow(unused_variables)] -impl From<&responses::ListfundsOutputs> for pb::ListfundsOutputs { - fn from(c: &responses::ListfundsOutputs) -> Self { +impl From for pb::ListfundsOutputs { + fn from(c: responses::ListfundsOutputs) -> Self { Self { txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid - output: c.output.clone(), // Rule #2 for type u32 + output: c.output, // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat scriptpubkey: hex::decode(&c.scriptpubkey).unwrap(), // Rule #2 for type hex - address: c.address.clone(), // Rule #2 for type string? - redeemscript: c.redeemscript.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + address: c.address, // Rule #2 for type string? + redeemscript: c.redeemscript.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? status: c.status as i32, - reserved: c.reserved.clone(), // Rule #2 for type boolean - blockheight: c.blockheight.clone(), // Rule #2 for type u32? + reserved: c.reserved, // Rule #2 for type boolean + blockheight: c.blockheight, // Rule #2 for type u32? } } } #[allow(unused_variables)] -impl From<&responses::ListfundsChannels> for pb::ListfundsChannels { - fn from(c: &responses::ListfundsChannels) -> Self { +impl From for pb::ListfundsChannels { + fn from(c: responses::ListfundsChannels) -> Self { Self { peer_id: c.peer_id.to_vec(), // Rule #2 for type pubkey our_amount_msat: Some(c.our_amount_msat.into()), // Rule #2 for type msat amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat funding_txid: hex::decode(&c.funding_txid).unwrap(), // Rule #2 for type txid - funding_output: c.funding_output.clone(), // Rule #2 for type u32 - connected: c.connected.clone(), // Rule #2 for type boolean + funding_output: c.funding_output, // Rule #2 for type u32 + connected: c.connected, // Rule #2 for type boolean state: c.state as i32, - short_channel_id: c.short_channel_id.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? + short_channel_id: c.short_channel_id.map(|v| v.to_string()), // Rule #2 for type short_channel_id? } } } #[allow(unused_variables)] -impl From<&responses::ListfundsResponse> for pb::ListfundsResponse { - fn from(c: &responses::ListfundsResponse) -> Self { +impl From for pb::ListfundsResponse { + fn from(c: responses::ListfundsResponse) -> Self { Self { - outputs: c.outputs.iter().map(|i| i.into()).collect(), // Rule #3 for type ListfundsOutputs - channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListfundsChannels + outputs: c.outputs.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListfundsOutputs + channels: c.channels.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListfundsChannels } } } #[allow(unused_variables)] -impl From<&responses::SendpayResponse> for pb::SendpayResponse { - fn from(c: &responses::SendpayResponse) -> Self { +impl From for pb::SendpayResponse { + fn from(c: responses::SendpayResponse) -> Self { Self { - id: c.id.clone(), // Rule #2 for type u64 - groupid: c.groupid.clone(), // Rule #2 for type u64? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + id: c.id, // Rule #2 for type u64 + groupid: c.groupid, // Rule #2 for type u64? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - created_at: c.created_at.clone(), // Rule #2 for type u64 - completed_at: c.completed_at.clone(), // Rule #2 for type u64? + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + created_at: c.created_at, // Rule #2 for type u64 + completed_at: c.completed_at, // Rule #2 for type u64? amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat - label: c.label.clone(), // Rule #2 for type string? - partid: c.partid.clone(), // Rule #2 for type u64? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? - message: c.message.clone(), // Rule #2 for type string? + label: c.label, // Rule #2 for type string? + partid: c.partid, // Rule #2 for type u64? + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? + message: c.message, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListchannelsChannels> for pb::ListchannelsChannels { - fn from(c: &responses::ListchannelsChannels) -> Self { +impl From for pb::ListchannelsChannels { + fn from(c: responses::ListchannelsChannels) -> Self { Self { source: c.source.to_vec(), // Rule #2 for type pubkey destination: c.destination.to_vec(), // Rule #2 for type pubkey short_channel_id: c.short_channel_id.to_string(), // Rule #2 for type short_channel_id - public: c.public.clone(), // Rule #2 for type boolean + public: c.public, // Rule #2 for type boolean amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat message_flags: c.message_flags.into(), // Rule #2 for type u8 channel_flags: c.channel_flags.into(), // Rule #2 for type u8 - active: c.active.clone(), // Rule #2 for type boolean - last_update: c.last_update.clone(), // Rule #2 for type u32 - base_fee_millisatoshi: c.base_fee_millisatoshi.clone(), // Rule #2 for type u32 - fee_per_millionth: c.fee_per_millionth.clone(), // Rule #2 for type u32 - delay: c.delay.clone(), // Rule #2 for type u32 + active: c.active, // Rule #2 for type boolean + last_update: c.last_update, // Rule #2 for type u32 + base_fee_millisatoshi: c.base_fee_millisatoshi, // Rule #2 for type u32 + fee_per_millionth: c.fee_per_millionth, // Rule #2 for type u32 + delay: c.delay, // Rule #2 for type u32 htlc_minimum_msat: Some(c.htlc_minimum_msat.into()), // Rule #2 for type msat htlc_maximum_msat: c.htlc_maximum_msat.map(|f| f.into()), // Rule #2 for type msat? features: hex::decode(&c.features).unwrap(), // Rule #2 for type hex @@ -268,57 +268,57 @@ impl From<&responses::ListchannelsChannels> for pb::ListchannelsChannels { } #[allow(unused_variables)] -impl From<&responses::ListchannelsResponse> for pb::ListchannelsResponse { - fn from(c: &responses::ListchannelsResponse) -> Self { +impl From for pb::ListchannelsResponse { + fn from(c: responses::ListchannelsResponse) -> Self { Self { - channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type ListchannelsChannels + channels: c.channels.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListchannelsChannels } } } #[allow(unused_variables)] -impl From<&responses::AddgossipResponse> for pb::AddgossipResponse { - fn from(c: &responses::AddgossipResponse) -> Self { +impl From for pb::AddgossipResponse { + fn from(c: responses::AddgossipResponse) -> Self { Self { } } } #[allow(unused_variables)] -impl From<&responses::AutocleaninvoiceResponse> for pb::AutocleaninvoiceResponse { - fn from(c: &responses::AutocleaninvoiceResponse) -> Self { +impl From for pb::AutocleaninvoiceResponse { + fn from(c: responses::AutocleaninvoiceResponse) -> Self { Self { - enabled: c.enabled.clone(), // Rule #2 for type boolean - expired_by: c.expired_by.clone(), // Rule #2 for type u64? - cycle_seconds: c.cycle_seconds.clone(), // Rule #2 for type u64? + enabled: c.enabled, // Rule #2 for type boolean + expired_by: c.expired_by, // Rule #2 for type u64? + cycle_seconds: c.cycle_seconds, // Rule #2 for type u64? } } } #[allow(unused_variables)] -impl From<&responses::CheckmessageResponse> for pb::CheckmessageResponse { - fn from(c: &responses::CheckmessageResponse) -> Self { +impl From for pb::CheckmessageResponse { + fn from(c: responses::CheckmessageResponse) -> Self { Self { - verified: c.verified.clone(), // Rule #2 for type boolean + verified: c.verified, // Rule #2 for type boolean pubkey: c.pubkey.to_vec(), // Rule #2 for type pubkey } } } #[allow(unused_variables)] -impl From<&responses::CloseResponse> for pb::CloseResponse { - fn from(c: &responses::CloseResponse) -> Self { +impl From for pb::CloseResponse { + fn from(c: responses::CloseResponse) -> Self { Self { item_type: c.item_type as i32, - tx: c.tx.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - txid: c.txid.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type txid? + tx: c.tx.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + txid: c.txid.map(|v| hex::decode(v).unwrap()), // Rule #2 for type txid? } } } #[allow(unused_variables)] -impl From<&responses::ConnectResponse> for pb::ConnectResponse { - fn from(c: &responses::ConnectResponse) -> Self { +impl From for pb::ConnectResponse { + fn from(c: responses::ConnectResponse) -> Self { Self { id: c.id.to_vec(), // Rule #2 for type pubkey features: hex::decode(&c.features).unwrap(), // Rule #2 for type hex @@ -328,441 +328,441 @@ impl From<&responses::ConnectResponse> for pb::ConnectResponse { } #[allow(unused_variables)] -impl From<&responses::CreateinvoiceResponse> for pb::CreateinvoiceResponse { - fn from(c: &responses::CreateinvoiceResponse) -> Self { +impl From for pb::CreateinvoiceResponse { + fn from(c: responses::CreateinvoiceResponse) -> Self { Self { - label: c.label.clone(), // Rule #2 for type string - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + label: c.label, // Rule #2 for type string + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? status: c.status as i32, - description: c.description.clone(), // Rule #2 for type string - expires_at: c.expires_at.clone(), // Rule #2 for type u64 - pay_index: c.pay_index.clone(), // Rule #2 for type u64? + description: c.description, // Rule #2 for type string + expires_at: c.expires_at, // Rule #2 for type u64 + pay_index: c.pay_index, // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? - paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? - local_offer_id: c.local_offer_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - payer_note: c.payer_note.clone(), // Rule #2 for type string? + paid_at: c.paid_at, // Rule #2 for type u64? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? + local_offer_id: c.local_offer_id.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + payer_note: c.payer_note, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::DatastoreResponse> for pb::DatastoreResponse { - fn from(c: &responses::DatastoreResponse) -> Self { +impl From for pb::DatastoreResponse { + fn from(c: responses::DatastoreResponse) -> Self { Self { - key: c.key.iter().map(|i| i.into()).collect(), // Rule #3 for type string - generation: c.generation.clone(), // Rule #2 for type u64? - hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - string: c.string.clone(), // Rule #2 for type string? + key: c.key.into_iter().map(|i| i.into()).collect(), // Rule #3 for type string + generation: c.generation, // Rule #2 for type u64? + hex: c.hex.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + string: c.string, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::CreateonionResponse> for pb::CreateonionResponse { - fn from(c: &responses::CreateonionResponse) -> Self { +impl From for pb::CreateonionResponse { + fn from(c: responses::CreateonionResponse) -> Self { Self { onion: hex::decode(&c.onion).unwrap(), // Rule #2 for type hex - shared_secrets: c.shared_secrets.iter().map(|i| i.clone().to_vec()).collect(), // Rule #3 for type secret + shared_secrets: c.shared_secrets.into_iter().map(|i| i.to_vec()).collect(), // Rule #3 for type secret } } } #[allow(unused_variables)] -impl From<&responses::DeldatastoreResponse> for pb::DeldatastoreResponse { - fn from(c: &responses::DeldatastoreResponse) -> Self { +impl From for pb::DeldatastoreResponse { + fn from(c: responses::DeldatastoreResponse) -> Self { Self { - key: c.key.iter().map(|i| i.into()).collect(), // Rule #3 for type string - generation: c.generation.clone(), // Rule #2 for type u64? - hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - string: c.string.clone(), // Rule #2 for type string? + key: c.key.into_iter().map(|i| i.into()).collect(), // Rule #3 for type string + generation: c.generation, // Rule #2 for type u64? + hex: c.hex.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + string: c.string, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::DelexpiredinvoiceResponse> for pb::DelexpiredinvoiceResponse { - fn from(c: &responses::DelexpiredinvoiceResponse) -> Self { +impl From for pb::DelexpiredinvoiceResponse { + fn from(c: responses::DelexpiredinvoiceResponse) -> Self { Self { } } } #[allow(unused_variables)] -impl From<&responses::DelinvoiceResponse> for pb::DelinvoiceResponse { - fn from(c: &responses::DelinvoiceResponse) -> Self { +impl From for pb::DelinvoiceResponse { + fn from(c: responses::DelinvoiceResponse) -> Self { Self { - label: c.label.clone(), // Rule #2 for type string - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? + label: c.label, // Rule #2 for type string + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - description: c.description.clone(), // Rule #2 for type string? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + description: c.description, // Rule #2 for type string? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, - expires_at: c.expires_at.clone(), // Rule #2 for type u64 - local_offer_id: c.local_offer_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - payer_note: c.payer_note.clone(), // Rule #2 for type string? + expires_at: c.expires_at, // Rule #2 for type u64 + local_offer_id: c.local_offer_id.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + payer_note: c.payer_note, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::InvoiceResponse> for pb::InvoiceResponse { - fn from(c: &responses::InvoiceResponse) -> Self { +impl From for pb::InvoiceResponse { + fn from(c: responses::InvoiceResponse) -> Self { Self { - bolt11: c.bolt11.clone(), // Rule #2 for type string - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash - payment_secret: c.payment_secret.clone().to_vec(), // Rule #2 for type secret - expires_at: c.expires_at.clone(), // Rule #2 for type u64 - warning_capacity: c.warning_capacity.clone(), // Rule #2 for type string? - warning_offline: c.warning_offline.clone(), // Rule #2 for type string? - warning_deadends: c.warning_deadends.clone(), // Rule #2 for type string? - warning_private_unused: c.warning_private_unused.clone(), // Rule #2 for type string? - warning_mpp: c.warning_mpp.clone(), // Rule #2 for type string? + bolt11: c.bolt11, // Rule #2 for type string + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash + payment_secret: c.payment_secret.to_vec(), // Rule #2 for type secret + expires_at: c.expires_at, // Rule #2 for type u64 + warning_capacity: c.warning_capacity, // Rule #2 for type string? + warning_offline: c.warning_offline, // Rule #2 for type string? + warning_deadends: c.warning_deadends, // Rule #2 for type string? + warning_private_unused: c.warning_private_unused, // Rule #2 for type string? + warning_mpp: c.warning_mpp, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListdatastoreDatastore> for pb::ListdatastoreDatastore { - fn from(c: &responses::ListdatastoreDatastore) -> Self { +impl From for pb::ListdatastoreDatastore { + fn from(c: responses::ListdatastoreDatastore) -> Self { Self { - key: c.key.iter().map(|i| i.into()).collect(), // Rule #3 for type string - generation: c.generation.clone(), // Rule #2 for type u64? - hex: c.hex.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - string: c.string.clone(), // Rule #2 for type string? + key: c.key.into_iter().map(|i| i.into()).collect(), // Rule #3 for type string + generation: c.generation, // Rule #2 for type u64? + hex: c.hex.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + string: c.string, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListdatastoreResponse> for pb::ListdatastoreResponse { - fn from(c: &responses::ListdatastoreResponse) -> Self { +impl From for pb::ListdatastoreResponse { + fn from(c: responses::ListdatastoreResponse) -> Self { Self { - datastore: c.datastore.iter().map(|i| i.into()).collect(), // Rule #3 for type ListdatastoreDatastore + datastore: c.datastore.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListdatastoreDatastore } } } #[allow(unused_variables)] -impl From<&responses::ListinvoicesInvoices> for pb::ListinvoicesInvoices { - fn from(c: &responses::ListinvoicesInvoices) -> Self { +impl From for pb::ListinvoicesInvoices { + fn from(c: responses::ListinvoicesInvoices) -> Self { Self { - label: c.label.clone(), // Rule #2 for type string - description: c.description.clone(), // Rule #2 for type string? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + label: c.label, // Rule #2 for type string + description: c.description, // Rule #2 for type string? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, - expires_at: c.expires_at.clone(), // Rule #2 for type u64 + expires_at: c.expires_at, // Rule #2 for type u64 amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - local_offer_id: c.local_offer_id.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - payer_note: c.payer_note.clone(), // Rule #2 for type string? - pay_index: c.pay_index.clone(), // Rule #2 for type u64? + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + local_offer_id: c.local_offer_id.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + payer_note: c.payer_note, // Rule #2 for type string? + pay_index: c.pay_index, // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? - paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? + paid_at: c.paid_at, // Rule #2 for type u64? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? } } } #[allow(unused_variables)] -impl From<&responses::ListinvoicesResponse> for pb::ListinvoicesResponse { - fn from(c: &responses::ListinvoicesResponse) -> Self { +impl From for pb::ListinvoicesResponse { + fn from(c: responses::ListinvoicesResponse) -> Self { Self { - invoices: c.invoices.iter().map(|i| i.into()).collect(), // Rule #3 for type ListinvoicesInvoices + invoices: c.invoices.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListinvoicesInvoices } } } #[allow(unused_variables)] -impl From<&responses::SendonionResponse> for pb::SendonionResponse { - fn from(c: &responses::SendonionResponse) -> Self { +impl From for pb::SendonionResponse { + fn from(c: responses::SendonionResponse) -> Self { Self { - id: c.id.clone(), // Rule #2 for type u64 - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + id: c.id, // Rule #2 for type u64 + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - created_at: c.created_at.clone(), // Rule #2 for type u64 + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + created_at: c.created_at, // Rule #2 for type u64 amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat - label: c.label.clone(), // Rule #2 for type string? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - partid: c.partid.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? - message: c.message.clone(), // Rule #2 for type string? + label: c.label, // Rule #2 for type string? + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + partid: c.partid, // Rule #2 for type u64? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? + message: c.message, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListsendpaysPayments> for pb::ListsendpaysPayments { - fn from(c: &responses::ListsendpaysPayments) -> Self { +impl From for pb::ListsendpaysPayments { + fn from(c: responses::ListsendpaysPayments) -> Self { Self { - id: c.id.clone(), // Rule #2 for type u64 - groupid: c.groupid.clone(), // Rule #2 for type u64 - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + id: c.id, // Rule #2 for type u64 + groupid: c.groupid, // Rule #2 for type u64 + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - created_at: c.created_at.clone(), // Rule #2 for type u64 + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + created_at: c.created_at, // Rule #2 for type u64 amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat - label: c.label.clone(), // Rule #2 for type string? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - description: c.description.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? - erroronion: c.erroronion.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + label: c.label, // Rule #2 for type string? + bolt11: c.bolt11, // Rule #2 for type string? + description: c.description, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? + erroronion: c.erroronion.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? } } } #[allow(unused_variables)] -impl From<&responses::ListsendpaysResponse> for pb::ListsendpaysResponse { - fn from(c: &responses::ListsendpaysResponse) -> Self { +impl From for pb::ListsendpaysResponse { + fn from(c: responses::ListsendpaysResponse) -> Self { Self { - payments: c.payments.iter().map(|i| i.into()).collect(), // Rule #3 for type ListsendpaysPayments + payments: c.payments.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListsendpaysPayments } } } #[allow(unused_variables)] -impl From<&responses::ListtransactionsTransactionsInputs> for pb::ListtransactionsTransactionsInputs { - fn from(c: &responses::ListtransactionsTransactionsInputs) -> Self { +impl From for pb::ListtransactionsTransactionsInputs { + fn from(c: responses::ListtransactionsTransactionsInputs) -> Self { Self { txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid - index: c.index.clone(), // Rule #2 for type u32 - sequence: c.sequence.clone(), // Rule #2 for type u32 + index: c.index, // Rule #2 for type u32 + sequence: c.sequence, // Rule #2 for type u32 item_type: c.item_type.map(|v| v as i32), - channel: c.channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? + channel: c.channel.map(|v| v.to_string()), // Rule #2 for type short_channel_id? } } } #[allow(unused_variables)] -impl From<&responses::ListtransactionsTransactionsOutputs> for pb::ListtransactionsTransactionsOutputs { - fn from(c: &responses::ListtransactionsTransactionsOutputs) -> Self { +impl From for pb::ListtransactionsTransactionsOutputs { + fn from(c: responses::ListtransactionsTransactionsOutputs) -> Self { Self { - index: c.index.clone(), // Rule #2 for type u32 + index: c.index, // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat script_pub_key: hex::decode(&c.script_pub_key).unwrap(), // Rule #2 for type hex item_type: c.item_type.map(|v| v as i32), - channel: c.channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? + channel: c.channel.map(|v| v.to_string()), // Rule #2 for type short_channel_id? } } } #[allow(unused_variables)] -impl From<&responses::ListtransactionsTransactions> for pb::ListtransactionsTransactions { - fn from(c: &responses::ListtransactionsTransactions) -> Self { +impl From for pb::ListtransactionsTransactions { + fn from(c: responses::ListtransactionsTransactions) -> Self { Self { hash: hex::decode(&c.hash).unwrap(), // Rule #2 for type txid rawtx: hex::decode(&c.rawtx).unwrap(), // Rule #2 for type hex - blockheight: c.blockheight.clone(), // Rule #2 for type u32 - txindex: c.txindex.clone(), // Rule #2 for type u32 - channel: c.channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? - locktime: c.locktime.clone(), // Rule #2 for type u32 - version: c.version.clone(), // Rule #2 for type u32 - inputs: c.inputs.iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsInputs - outputs: c.outputs.iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsOutputs + blockheight: c.blockheight, // Rule #2 for type u32 + txindex: c.txindex, // Rule #2 for type u32 + channel: c.channel.map(|v| v.to_string()), // Rule #2 for type short_channel_id? + locktime: c.locktime, // Rule #2 for type u32 + version: c.version, // Rule #2 for type u32 + inputs: c.inputs.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsInputs + outputs: c.outputs.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactionsOutputs } } } #[allow(unused_variables)] -impl From<&responses::ListtransactionsResponse> for pb::ListtransactionsResponse { - fn from(c: &responses::ListtransactionsResponse) -> Self { +impl From for pb::ListtransactionsResponse { + fn from(c: responses::ListtransactionsResponse) -> Self { Self { - transactions: c.transactions.iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactions + transactions: c.transactions.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListtransactionsTransactions } } } #[allow(unused_variables)] -impl From<&responses::PayResponse> for pb::PayResponse { - fn from(c: &responses::PayResponse) -> Self { +impl From for pb::PayResponse { + fn from(c: responses::PayResponse) -> Self { Self { - payment_preimage: c.payment_preimage.clone().to_vec(), // Rule #2 for type secret - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash - created_at: c.created_at.clone(), // Rule #2 for type number - parts: c.parts.clone(), // Rule #2 for type u32 + payment_preimage: c.payment_preimage.to_vec(), // Rule #2 for type secret + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash + created_at: c.created_at, // Rule #2 for type number + parts: c.parts, // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat - warning_partial_completion: c.warning_partial_completion.clone(), // Rule #2 for type string? + warning_partial_completion: c.warning_partial_completion, // Rule #2 for type string? status: c.status as i32, } } } #[allow(unused_variables)] -impl From<&responses::ListnodesNodesAddresses> for pb::ListnodesNodesAddresses { - fn from(c: &responses::ListnodesNodesAddresses) -> Self { +impl From for pb::ListnodesNodesAddresses { + fn from(c: responses::ListnodesNodesAddresses) -> Self { Self { item_type: c.item_type as i32, port: c.port.into(), // Rule #2 for type u16 - address: c.address.clone(), // Rule #2 for type string? + address: c.address, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::ListnodesNodes> for pb::ListnodesNodes { - fn from(c: &responses::ListnodesNodes) -> Self { +impl From for pb::ListnodesNodes { + fn from(c: responses::ListnodesNodes) -> Self { Self { nodeid: c.nodeid.to_vec(), // Rule #2 for type pubkey - last_timestamp: c.last_timestamp.clone(), // Rule #2 for type u32? - alias: c.alias.clone(), // Rule #2 for type string? - color: c.color.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - features: c.features.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - addresses: c.addresses.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + last_timestamp: c.last_timestamp, // Rule #2 for type u32? + alias: c.alias, // Rule #2 for type string? + color: c.color.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + features: c.features.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + addresses: c.addresses.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 } } } #[allow(unused_variables)] -impl From<&responses::ListnodesResponse> for pb::ListnodesResponse { - fn from(c: &responses::ListnodesResponse) -> Self { +impl From for pb::ListnodesResponse { + fn from(c: responses::ListnodesResponse) -> Self { Self { - nodes: c.nodes.iter().map(|i| i.into()).collect(), // Rule #3 for type ListnodesNodes + nodes: c.nodes.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListnodesNodes } } } #[allow(unused_variables)] -impl From<&responses::WaitanyinvoiceResponse> for pb::WaitanyinvoiceResponse { - fn from(c: &responses::WaitanyinvoiceResponse) -> Self { +impl From for pb::WaitanyinvoiceResponse { + fn from(c: responses::WaitanyinvoiceResponse) -> Self { Self { - label: c.label.clone(), // Rule #2 for type string - description: c.description.clone(), // Rule #2 for type string - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + label: c.label, // Rule #2 for type string + description: c.description, // Rule #2 for type string + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, - expires_at: c.expires_at.clone(), // Rule #2 for type u64 + expires_at: c.expires_at, // Rule #2 for type u64 amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - pay_index: c.pay_index.clone(), // Rule #2 for type u64? + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + pay_index: c.pay_index, // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? - paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? + paid_at: c.paid_at, // Rule #2 for type u64? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? } } } #[allow(unused_variables)] -impl From<&responses::WaitinvoiceResponse> for pb::WaitinvoiceResponse { - fn from(c: &responses::WaitinvoiceResponse) -> Self { +impl From for pb::WaitinvoiceResponse { + fn from(c: responses::WaitinvoiceResponse) -> Self { Self { - label: c.label.clone(), // Rule #2 for type string - description: c.description.clone(), // Rule #2 for type string - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + label: c.label, // Rule #2 for type string + description: c.description, // Rule #2 for type string + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, - expires_at: c.expires_at.clone(), // Rule #2 for type u64 + expires_at: c.expires_at, // Rule #2 for type u64 amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - pay_index: c.pay_index.clone(), // Rule #2 for type u64? + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + pay_index: c.pay_index, // Rule #2 for type u64? amount_received_msat: c.amount_received_msat.map(|f| f.into()), // Rule #2 for type msat? - paid_at: c.paid_at.clone(), // Rule #2 for type u64? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? + paid_at: c.paid_at, // Rule #2 for type u64? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? } } } #[allow(unused_variables)] -impl From<&responses::WaitsendpayResponse> for pb::WaitsendpayResponse { - fn from(c: &responses::WaitsendpayResponse) -> Self { +impl From for pb::WaitsendpayResponse { + fn from(c: responses::WaitsendpayResponse) -> Self { Self { - id: c.id.clone(), // Rule #2 for type u64 - groupid: c.groupid.clone(), // Rule #2 for type u64? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash + id: c.id, // Rule #2 for type u64 + groupid: c.groupid, // Rule #2 for type u64? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash status: c.status as i32, amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - created_at: c.created_at.clone(), // Rule #2 for type u64 - completed_at: c.completed_at.clone(), // Rule #2 for type number? + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + created_at: c.created_at, // Rule #2 for type u64 + completed_at: c.completed_at, // Rule #2 for type number? amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat - label: c.label.clone(), // Rule #2 for type string? - partid: c.partid.clone(), // Rule #2 for type u64? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - payment_preimage: c.payment_preimage.clone().map(|v| v.to_vec()), // Rule #2 for type secret? + label: c.label, // Rule #2 for type string? + partid: c.partid, // Rule #2 for type u64? + bolt11: c.bolt11, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + payment_preimage: c.payment_preimage.map(|v| v.to_vec()), // Rule #2 for type secret? } } } #[allow(unused_variables)] -impl From<&responses::NewaddrResponse> for pb::NewaddrResponse { - fn from(c: &responses::NewaddrResponse) -> Self { +impl From for pb::NewaddrResponse { + fn from(c: responses::NewaddrResponse) -> Self { Self { - bech32: c.bech32.clone(), // Rule #2 for type string? - p2sh_segwit: c.p2sh_segwit.clone(), // Rule #2 for type string? + bech32: c.bech32, // Rule #2 for type string? + p2sh_segwit: c.p2sh_segwit, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::WithdrawResponse> for pb::WithdrawResponse { - fn from(c: &responses::WithdrawResponse) -> Self { +impl From for pb::WithdrawResponse { + fn from(c: responses::WithdrawResponse) -> Self { Self { tx: hex::decode(&c.tx).unwrap(), // Rule #2 for type hex txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid - psbt: c.psbt.clone(), // Rule #2 for type string + psbt: c.psbt, // Rule #2 for type string } } } #[allow(unused_variables)] -impl From<&responses::KeysendResponse> for pb::KeysendResponse { - fn from(c: &responses::KeysendResponse) -> Self { +impl From for pb::KeysendResponse { + fn from(c: responses::KeysendResponse) -> Self { Self { - payment_preimage: c.payment_preimage.clone().to_vec(), // Rule #2 for type secret - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - payment_hash: c.payment_hash.clone().to_vec(), // Rule #2 for type hash - created_at: c.created_at.clone(), // Rule #2 for type number - parts: c.parts.clone(), // Rule #2 for type u32 + payment_preimage: c.payment_preimage.to_vec(), // Rule #2 for type secret + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + payment_hash: c.payment_hash.to_vec(), // Rule #2 for type hash + created_at: c.created_at, // Rule #2 for type number + parts: c.parts, // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat amount_sent_msat: Some(c.amount_sent_msat.into()), // Rule #2 for type msat - warning_partial_completion: c.warning_partial_completion.clone(), // Rule #2 for type string? + warning_partial_completion: c.warning_partial_completion, // Rule #2 for type string? status: c.status as i32, } } } #[allow(unused_variables)] -impl From<&responses::FundpsbtReservations> for pb::FundpsbtReservations { - fn from(c: &responses::FundpsbtReservations) -> Self { +impl From for pb::FundpsbtReservations { + fn from(c: responses::FundpsbtReservations) -> Self { Self { txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid - vout: c.vout.clone(), // Rule #2 for type u32 - was_reserved: c.was_reserved.clone(), // Rule #2 for type boolean - reserved: c.reserved.clone(), // Rule #2 for type boolean - reserved_to_block: c.reserved_to_block.clone(), // Rule #2 for type u32 + vout: c.vout, // Rule #2 for type u32 + was_reserved: c.was_reserved, // Rule #2 for type boolean + reserved: c.reserved, // Rule #2 for type boolean + reserved_to_block: c.reserved_to_block, // Rule #2 for type u32 } } } #[allow(unused_variables)] -impl From<&responses::FundpsbtResponse> for pb::FundpsbtResponse { - fn from(c: &responses::FundpsbtResponse) -> Self { +impl From for pb::FundpsbtResponse { + fn from(c: responses::FundpsbtResponse) -> Self { Self { - psbt: c.psbt.clone(), // Rule #2 for type string - feerate_per_kw: c.feerate_per_kw.clone(), // Rule #2 for type u32 - estimated_final_weight: c.estimated_final_weight.clone(), // Rule #2 for type u32 + psbt: c.psbt, // Rule #2 for type string + feerate_per_kw: c.feerate_per_kw, // Rule #2 for type u32 + estimated_final_weight: c.estimated_final_weight, // Rule #2 for type u32 excess_msat: Some(c.excess_msat.into()), // Rule #2 for type msat - change_outnum: c.change_outnum.clone(), // Rule #2 for type u32? - reservations: c.reservations.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + change_outnum: c.change_outnum, // Rule #2 for type u32? + reservations: c.reservations.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 } } } #[allow(unused_variables)] -impl From<&responses::SendpsbtResponse> for pb::SendpsbtResponse { - fn from(c: &responses::SendpsbtResponse) -> Self { +impl From for pb::SendpsbtResponse { + fn from(c: responses::SendpsbtResponse) -> Self { Self { tx: hex::decode(&c.tx).unwrap(), // Rule #2 for type hex txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid @@ -771,44 +771,44 @@ impl From<&responses::SendpsbtResponse> for pb::SendpsbtResponse { } #[allow(unused_variables)] -impl From<&responses::SignpsbtResponse> for pb::SignpsbtResponse { - fn from(c: &responses::SignpsbtResponse) -> Self { +impl From for pb::SignpsbtResponse { + fn from(c: responses::SignpsbtResponse) -> Self { Self { - signed_psbt: c.signed_psbt.clone(), // Rule #2 for type string + signed_psbt: c.signed_psbt, // Rule #2 for type string } } } #[allow(unused_variables)] -impl From<&responses::UtxopsbtReservations> for pb::UtxopsbtReservations { - fn from(c: &responses::UtxopsbtReservations) -> Self { +impl From for pb::UtxopsbtReservations { + fn from(c: responses::UtxopsbtReservations) -> Self { Self { txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid - vout: c.vout.clone(), // Rule #2 for type u32 - was_reserved: c.was_reserved.clone(), // Rule #2 for type boolean - reserved: c.reserved.clone(), // Rule #2 for type boolean - reserved_to_block: c.reserved_to_block.clone(), // Rule #2 for type u32 + vout: c.vout, // Rule #2 for type u32 + was_reserved: c.was_reserved, // Rule #2 for type boolean + reserved: c.reserved, // Rule #2 for type boolean + reserved_to_block: c.reserved_to_block, // Rule #2 for type u32 } } } #[allow(unused_variables)] -impl From<&responses::UtxopsbtResponse> for pb::UtxopsbtResponse { - fn from(c: &responses::UtxopsbtResponse) -> Self { +impl From for pb::UtxopsbtResponse { + fn from(c: responses::UtxopsbtResponse) -> Self { Self { - psbt: c.psbt.clone(), // Rule #2 for type string - feerate_per_kw: c.feerate_per_kw.clone(), // Rule #2 for type u32 - estimated_final_weight: c.estimated_final_weight.clone(), // Rule #2 for type u32 + psbt: c.psbt, // Rule #2 for type string + feerate_per_kw: c.feerate_per_kw, // Rule #2 for type u32 + estimated_final_weight: c.estimated_final_weight, // Rule #2 for type u32 excess_msat: Some(c.excess_msat.into()), // Rule #2 for type msat - change_outnum: c.change_outnum.clone(), // Rule #2 for type u32? - reservations: c.reservations.as_ref().map(|arr| arr.iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + change_outnum: c.change_outnum, // Rule #2 for type u32? + reservations: c.reservations.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 } } } #[allow(unused_variables)] -impl From<&responses::TxdiscardResponse> for pb::TxdiscardResponse { - fn from(c: &responses::TxdiscardResponse) -> Self { +impl From for pb::TxdiscardResponse { + fn from(c: responses::TxdiscardResponse) -> Self { Self { unsigned_tx: hex::decode(&c.unsigned_tx).unwrap(), // Rule #2 for type hex txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid @@ -817,10 +817,10 @@ impl From<&responses::TxdiscardResponse> for pb::TxdiscardResponse { } #[allow(unused_variables)] -impl From<&responses::TxprepareResponse> for pb::TxprepareResponse { - fn from(c: &responses::TxprepareResponse) -> Self { +impl From for pb::TxprepareResponse { + fn from(c: responses::TxprepareResponse) -> Self { Self { - psbt: c.psbt.clone(), // Rule #2 for type string + psbt: c.psbt, // Rule #2 for type string unsigned_tx: hex::decode(&c.unsigned_tx).unwrap(), // Rule #2 for type hex txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid } @@ -828,10 +828,10 @@ impl From<&responses::TxprepareResponse> for pb::TxprepareResponse { } #[allow(unused_variables)] -impl From<&responses::TxsendResponse> for pb::TxsendResponse { - fn from(c: &responses::TxsendResponse) -> Self { +impl From for pb::TxsendResponse { + fn from(c: responses::TxsendResponse) -> Self { Self { - psbt: c.psbt.clone(), // Rule #2 for type string + psbt: c.psbt, // Rule #2 for type string tx: hex::decode(&c.tx).unwrap(), // Rule #2 for type hex txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid } @@ -839,70 +839,70 @@ impl From<&responses::TxsendResponse> for pb::TxsendResponse { } #[allow(unused_variables)] -impl From<&responses::DisconnectResponse> for pb::DisconnectResponse { - fn from(c: &responses::DisconnectResponse) -> Self { +impl From for pb::DisconnectResponse { + fn from(c: responses::DisconnectResponse) -> Self { Self { } } } #[allow(unused_variables)] -impl From<&responses::FeeratesResponse> for pb::FeeratesResponse { - fn from(c: &responses::FeeratesResponse) -> Self { +impl From for pb::FeeratesResponse { + fn from(c: responses::FeeratesResponse) -> Self { Self { - warning_missing_feerates: c.warning_missing_feerates.clone(), // Rule #2 for type string? + warning_missing_feerates: c.warning_missing_feerates, // Rule #2 for type string? } } } #[allow(unused_variables)] -impl From<&responses::FundchannelResponse> for pb::FundchannelResponse { - fn from(c: &responses::FundchannelResponse) -> Self { +impl From for pb::FundchannelResponse { + fn from(c: responses::FundchannelResponse) -> Self { Self { tx: hex::decode(&c.tx).unwrap(), // Rule #2 for type hex txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid - outnum: c.outnum.clone(), // Rule #2 for type u32 + outnum: c.outnum, // Rule #2 for type u32 channel_id: hex::decode(&c.channel_id).unwrap(), // Rule #2 for type hex - close_to: c.close_to.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - mindepth: c.mindepth.clone(), // Rule #2 for type u32? + close_to: c.close_to.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + mindepth: c.mindepth, // Rule #2 for type u32? } } } #[allow(unused_variables)] -impl From<&responses::GetrouteRoute> for pb::GetrouteRoute { - fn from(c: &responses::GetrouteRoute) -> Self { +impl From for pb::GetrouteRoute { + fn from(c: responses::GetrouteRoute) -> Self { Self { id: c.id.to_vec(), // Rule #2 for type pubkey channel: c.channel.to_string(), // Rule #2 for type short_channel_id - direction: c.direction.clone(), // Rule #2 for type u32 + direction: c.direction, // Rule #2 for type u32 amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat - delay: c.delay.clone(), // Rule #2 for type u32 + delay: c.delay, // Rule #2 for type u32 style: c.style as i32, } } } #[allow(unused_variables)] -impl From<&responses::GetrouteResponse> for pb::GetrouteResponse { - fn from(c: &responses::GetrouteResponse) -> Self { +impl From for pb::GetrouteResponse { + fn from(c: responses::GetrouteResponse) -> Self { Self { - route: c.route.iter().map(|i| i.into()).collect(), // Rule #3 for type GetrouteRoute + route: c.route.into_iter().map(|i| i.into()).collect(), // Rule #3 for type GetrouteRoute } } } #[allow(unused_variables)] -impl From<&responses::ListforwardsForwards> for pb::ListforwardsForwards { - fn from(c: &responses::ListforwardsForwards) -> Self { +impl From for pb::ListforwardsForwards { + fn from(c: responses::ListforwardsForwards) -> Self { Self { in_channel: c.in_channel.to_string(), // Rule #2 for type short_channel_id - in_htlc_id: c.in_htlc_id.clone(), // Rule #2 for type u64 + in_htlc_id: c.in_htlc_id, // Rule #2 for type u64 in_msat: Some(c.in_msat.into()), // Rule #2 for type msat status: c.status as i32, - received_time: c.received_time.clone(), // Rule #2 for type number - out_channel: c.out_channel.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? - out_htlc_id: c.out_htlc_id.clone(), // Rule #2 for type u64? + received_time: c.received_time, // Rule #2 for type number + out_channel: c.out_channel.map(|v| v.to_string()), // Rule #2 for type short_channel_id? + out_htlc_id: c.out_htlc_id, // Rule #2 for type u64? style: c.style.map(|v| v as i32), fee_msat: c.fee_msat.map(|f| f.into()), // Rule #2 for type msat? out_msat: c.out_msat.map(|f| f.into()), // Rule #2 for type msat? @@ -911,46 +911,46 @@ impl From<&responses::ListforwardsForwards> for pb::ListforwardsForwards { } #[allow(unused_variables)] -impl From<&responses::ListforwardsResponse> for pb::ListforwardsResponse { - fn from(c: &responses::ListforwardsResponse) -> Self { +impl From for pb::ListforwardsResponse { + fn from(c: responses::ListforwardsResponse) -> Self { Self { - forwards: c.forwards.iter().map(|i| i.into()).collect(), // Rule #3 for type ListforwardsForwards + forwards: c.forwards.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListforwardsForwards } } } #[allow(unused_variables)] -impl From<&responses::ListpaysPays> for pb::ListpaysPays { - fn from(c: &responses::ListpaysPays) -> Self { +impl From for pb::ListpaysPays { + fn from(c: responses::ListpaysPays) -> Self { Self { payment_hash: hex::decode(&c.payment_hash).unwrap(), // Rule #2 for type hex status: c.status as i32, - destination: c.destination.as_ref().map(|v| v.to_vec()), // Rule #2 for type pubkey? - created_at: c.created_at.clone(), // Rule #2 for type u64 - completed_at: c.completed_at.clone(), // Rule #2 for type u64? - label: c.label.clone(), // Rule #2 for type string? - bolt11: c.bolt11.clone(), // Rule #2 for type string? - description: c.description.clone(), // Rule #2 for type string? - bolt12: c.bolt12.clone(), // Rule #2 for type string? - preimage: c.preimage.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? - number_of_parts: c.number_of_parts.clone(), // Rule #2 for type u64? - erroronion: c.erroronion.as_ref().map(|v| hex::decode(&v).unwrap()), // Rule #2 for type hex? + destination: c.destination.map(|v| v.to_vec()), // Rule #2 for type pubkey? + created_at: c.created_at, // Rule #2 for type u64 + completed_at: c.completed_at, // Rule #2 for type u64? + label: c.label, // Rule #2 for type string? + bolt11: c.bolt11, // Rule #2 for type string? + description: c.description, // Rule #2 for type string? + bolt12: c.bolt12, // Rule #2 for type string? + preimage: c.preimage.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + number_of_parts: c.number_of_parts, // Rule #2 for type u64? + erroronion: c.erroronion.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? } } } #[allow(unused_variables)] -impl From<&responses::ListpaysResponse> for pb::ListpaysResponse { - fn from(c: &responses::ListpaysResponse) -> Self { +impl From for pb::ListpaysResponse { + fn from(c: responses::ListpaysResponse) -> Self { Self { - pays: c.pays.iter().map(|i| i.into()).collect(), // Rule #3 for type ListpaysPays + pays: c.pays.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListpaysPays } } } #[allow(unused_variables)] -impl From<&responses::PingResponse> for pb::PingResponse { - fn from(c: &responses::PingResponse) -> Self { +impl From for pb::PingResponse { + fn from(c: responses::PingResponse) -> Self { Self { totlen: c.totlen.into(), // Rule #2 for type u16 } @@ -958,56 +958,56 @@ impl From<&responses::PingResponse> for pb::PingResponse { } #[allow(unused_variables)] -impl From<&responses::SignmessageResponse> for pb::SignmessageResponse { - fn from(c: &responses::SignmessageResponse) -> Self { +impl From for pb::SignmessageResponse { + fn from(c: responses::SignmessageResponse) -> Self { Self { signature: hex::decode(&c.signature).unwrap(), // Rule #2 for type hex recid: hex::decode(&c.recid).unwrap(), // Rule #2 for type hex - zbase: c.zbase.clone(), // Rule #2 for type string + zbase: c.zbase, // Rule #2 for type string } } } #[allow(unused_variables)] -impl From<&responses::StopResponse> for pb::StopResponse { - fn from(c: &responses::StopResponse) -> Self { +impl From for pb::StopResponse { + fn from(c: responses::StopResponse) -> Self { Self { } } } #[allow(unused_variables)] -impl From<&pb::GetinfoRequest> for requests::GetinfoRequest { - fn from(c: &pb::GetinfoRequest) -> Self { +impl From for requests::GetinfoRequest { + fn from(c: pb::GetinfoRequest) -> Self { Self { } } } #[allow(unused_variables)] -impl From<&pb::ListpeersRequest> for requests::ListpeersRequest { - fn from(c: &pb::ListpeersRequest) -> Self { +impl From for requests::ListpeersRequest { + fn from(c: pb::ListpeersRequest) -> Self { Self { - id: c.id.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? - level: c.level.clone(), // Rule #1 for type string? + id: c.id.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? + level: c.level, // Rule #1 for type string? } } } #[allow(unused_variables)] -impl From<&pb::ListfundsRequest> for requests::ListfundsRequest { - fn from(c: &pb::ListfundsRequest) -> Self { +impl From for requests::ListfundsRequest { + fn from(c: pb::ListfundsRequest) -> Self { Self { - spent: c.spent.clone(), // Rule #1 for type boolean? + spent: c.spent, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::SendpayRoute> for requests::SendpayRoute { - fn from(c: &pb::SendpayRoute) -> Self { +impl From for requests::SendpayRoute { + fn from(c: pb::SendpayRoute) -> Self { Self { - amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat + amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey delay: c.delay as u16, // Rule #1 for type u16 channel: cln_rpc::primitives::ShortChannelId::from_str(&c.channel).unwrap(), // Rule #1 for type short_channel_id @@ -1016,36 +1016,36 @@ impl From<&pb::SendpayRoute> for requests::SendpayRoute { } #[allow(unused_variables)] -impl From<&pb::SendpayRequest> for requests::SendpayRequest { - fn from(c: &pb::SendpayRequest) -> Self { +impl From for requests::SendpayRequest { + fn from(c: pb::SendpayRequest) -> Self { Self { - route: c.route.iter().map(|s| s.into()).collect(), // Rule #4 - payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash - label: c.label.clone(), // Rule #1 for type string? - amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat? - bolt11: c.bolt11.clone(), // Rule #1 for type string? - payment_secret: c.payment_secret.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type secret? + route: c.route.into_iter().map(|s| s.into()).collect(), // Rule #4 + payment_hash: c.payment_hash.try_into().unwrap(), // Rule #1 for type hash + label: c.label, // Rule #1 for type string? + amount_msat: c.amount_msat.map(|a| a.into()), // Rule #1 for type msat? + bolt11: c.bolt11, // Rule #1 for type string? + payment_secret: c.payment_secret.map(|v| v.try_into().unwrap()), // Rule #1 for type secret? partid: c.partid.map(|v| v as u16), // Rule #1 for type u16? - localofferid: c.localofferid.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? - groupid: c.groupid.clone(), // Rule #1 for type u64? + localofferid: c.localofferid.map(|v| hex::encode(v)), // Rule #1 for type hex? + groupid: c.groupid, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::ListchannelsRequest> for requests::ListchannelsRequest { - fn from(c: &pb::ListchannelsRequest) -> Self { +impl From for requests::ListchannelsRequest { + fn from(c: pb::ListchannelsRequest) -> Self { Self { - short_channel_id: c.short_channel_id.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? - source: c.source.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? - destination: c.destination.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? + short_channel_id: c.short_channel_id.map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? + source: c.source.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? + destination: c.destination.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? } } } #[allow(unused_variables)] -impl From<&pb::AddgossipRequest> for requests::AddgossipRequest { - fn from(c: &pb::AddgossipRequest) -> Self { +impl From for requests::AddgossipRequest { + fn from(c: pb::AddgossipRequest) -> Self { Self { message: hex::encode(&c.message), // Rule #1 for type hex } @@ -1053,79 +1053,79 @@ impl From<&pb::AddgossipRequest> for requests::AddgossipRequest { } #[allow(unused_variables)] -impl From<&pb::AutocleaninvoiceRequest> for requests::AutocleaninvoiceRequest { - fn from(c: &pb::AutocleaninvoiceRequest) -> Self { +impl From for requests::AutocleaninvoiceRequest { + fn from(c: pb::AutocleaninvoiceRequest) -> Self { Self { - expired_by: c.expired_by.clone(), // Rule #1 for type u64? - cycle_seconds: c.cycle_seconds.clone(), // Rule #1 for type u64? + expired_by: c.expired_by, // Rule #1 for type u64? + cycle_seconds: c.cycle_seconds, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::CheckmessageRequest> for requests::CheckmessageRequest { - fn from(c: &pb::CheckmessageRequest) -> Self { +impl From for requests::CheckmessageRequest { + fn from(c: pb::CheckmessageRequest) -> Self { Self { - message: c.message.clone(), // Rule #1 for type string - zbase: c.zbase.clone(), // Rule #1 for type string - pubkey: c.pubkey.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? + message: c.message, // Rule #1 for type string + zbase: c.zbase, // Rule #1 for type string + pubkey: c.pubkey.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? } } } #[allow(unused_variables)] -impl From<&pb::CloseRequest> for requests::CloseRequest { - fn from(c: &pb::CloseRequest) -> Self { +impl From for requests::CloseRequest { + fn from(c: pb::CloseRequest) -> Self { Self { - id: c.id.clone(), // Rule #1 for type string - unilateraltimeout: c.unilateraltimeout.clone(), // Rule #1 for type u32? - destination: c.destination.clone(), // Rule #1 for type string? - fee_negotiation_step: c.fee_negotiation_step.clone(), // Rule #1 for type string? - wrong_funding: c.wrong_funding.as_ref().map(|a| a.into()), // Rule #1 for type outpoint? - force_lease_closed: c.force_lease_closed.clone(), // Rule #1 for type boolean? - feerange: Some(c.feerange.iter().map(|s| s.into()).collect()), // Rule #4 + id: c.id, // Rule #1 for type string + unilateraltimeout: c.unilateraltimeout, // Rule #1 for type u32? + destination: c.destination, // Rule #1 for type string? + fee_negotiation_step: c.fee_negotiation_step, // Rule #1 for type string? + wrong_funding: c.wrong_funding.map(|a| a.into()), // Rule #1 for type outpoint? + force_lease_closed: c.force_lease_closed, // Rule #1 for type boolean? + feerange: Some(c.feerange.into_iter().map(|s| s.into()).collect()), // Rule #4 } } } #[allow(unused_variables)] -impl From<&pb::ConnectRequest> for requests::ConnectRequest { - fn from(c: &pb::ConnectRequest) -> Self { +impl From for requests::ConnectRequest { + fn from(c: pb::ConnectRequest) -> Self { Self { - id: c.id.clone(), // Rule #1 for type string - host: c.host.clone(), // Rule #1 for type string? + id: c.id, // Rule #1 for type string + host: c.host, // Rule #1 for type string? port: c.port.map(|v| v as u16), // Rule #1 for type u16? } } } #[allow(unused_variables)] -impl From<&pb::CreateinvoiceRequest> for requests::CreateinvoiceRequest { - fn from(c: &pb::CreateinvoiceRequest) -> Self { +impl From for requests::CreateinvoiceRequest { + fn from(c: pb::CreateinvoiceRequest) -> Self { Self { - invstring: c.invstring.clone(), // Rule #1 for type string - label: c.label.clone(), // Rule #1 for type string + invstring: c.invstring, // Rule #1 for type string + label: c.label, // Rule #1 for type string preimage: hex::encode(&c.preimage), // Rule #1 for type hex } } } #[allow(unused_variables)] -impl From<&pb::DatastoreRequest> for requests::DatastoreRequest { - fn from(c: &pb::DatastoreRequest) -> Self { +impl From for requests::DatastoreRequest { + fn from(c: pb::DatastoreRequest) -> Self { Self { - key: c.key.iter().map(|s| s.into()).collect(), // Rule #4 - string: c.string.clone(), // Rule #1 for type string? - hex: c.hex.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? + key: c.key.into_iter().map(|s| s.into()).collect(), // Rule #4 + string: c.string, // Rule #1 for type string? + hex: c.hex.map(|v| hex::encode(v)), // Rule #1 for type hex? mode: c.mode.map(|v| v.try_into().unwrap()), - generation: c.generation.clone(), // Rule #1 for type u64? + generation: c.generation, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::CreateonionHops> for requests::CreateonionHops { - fn from(c: &pb::CreateonionHops) -> Self { +impl From for requests::CreateonionHops { + fn from(c: pb::CreateonionHops) -> Self { Self { pubkey: cln_rpc::primitives::Pubkey::from_slice(&c.pubkey).unwrap(), // Rule #1 for type pubkey payload: hex::encode(&c.payload), // Rule #1 for type hex @@ -1134,185 +1134,185 @@ impl From<&pb::CreateonionHops> for requests::CreateonionHops { } #[allow(unused_variables)] -impl From<&pb::CreateonionRequest> for requests::CreateonionRequest { - fn from(c: &pb::CreateonionRequest) -> Self { +impl From for requests::CreateonionRequest { + fn from(c: pb::CreateonionRequest) -> Self { Self { - hops: c.hops.iter().map(|s| s.into()).collect(), // Rule #4 + hops: c.hops.into_iter().map(|s| s.into()).collect(), // Rule #4 assocdata: hex::encode(&c.assocdata), // Rule #1 for type hex - session_key: c.session_key.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type secret? + session_key: c.session_key.map(|v| v.try_into().unwrap()), // Rule #1 for type secret? onion_size: c.onion_size.map(|v| v as u16), // Rule #1 for type u16? } } } #[allow(unused_variables)] -impl From<&pb::DeldatastoreRequest> for requests::DeldatastoreRequest { - fn from(c: &pb::DeldatastoreRequest) -> Self { +impl From for requests::DeldatastoreRequest { + fn from(c: pb::DeldatastoreRequest) -> Self { Self { - key: c.key.iter().map(|s| s.into()).collect(), // Rule #4 - generation: c.generation.clone(), // Rule #1 for type u64? + key: c.key.into_iter().map(|s| s.into()).collect(), // Rule #4 + generation: c.generation, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::DelexpiredinvoiceRequest> for requests::DelexpiredinvoiceRequest { - fn from(c: &pb::DelexpiredinvoiceRequest) -> Self { +impl From for requests::DelexpiredinvoiceRequest { + fn from(c: pb::DelexpiredinvoiceRequest) -> Self { Self { - maxexpirytime: c.maxexpirytime.clone(), // Rule #1 for type u64? + maxexpirytime: c.maxexpirytime, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::DelinvoiceRequest> for requests::DelinvoiceRequest { - fn from(c: &pb::DelinvoiceRequest) -> Self { +impl From for requests::DelinvoiceRequest { + fn from(c: pb::DelinvoiceRequest) -> Self { Self { - label: c.label.clone(), // Rule #1 for type string + label: c.label, // Rule #1 for type string status: c.status.try_into().unwrap(), - desconly: c.desconly.clone(), // Rule #1 for type boolean? + desconly: c.desconly, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::InvoiceRequest> for requests::InvoiceRequest { - fn from(c: &pb::InvoiceRequest) -> Self { +impl From for requests::InvoiceRequest { + fn from(c: pb::InvoiceRequest) -> Self { Self { - amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat_or_any - description: c.description.clone(), // Rule #1 for type string - label: c.label.clone(), // Rule #1 for type string - expiry: c.expiry.clone(), // Rule #1 for type u64? - fallbacks: Some(c.fallbacks.iter().map(|s| s.into()).collect()), // Rule #4 - preimage: c.preimage.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? - exposeprivatechannels: c.exposeprivatechannels.clone(), // Rule #1 for type boolean? - cltv: c.cltv.clone(), // Rule #1 for type u32? - deschashonly: c.deschashonly.clone(), // Rule #1 for type boolean? + amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat_or_any + description: c.description, // Rule #1 for type string + label: c.label, // Rule #1 for type string + expiry: c.expiry, // Rule #1 for type u64? + fallbacks: Some(c.fallbacks.into_iter().map(|s| s.into()).collect()), // Rule #4 + preimage: c.preimage.map(|v| hex::encode(v)), // Rule #1 for type hex? + exposeprivatechannels: c.exposeprivatechannels, // Rule #1 for type boolean? + cltv: c.cltv, // Rule #1 for type u32? + deschashonly: c.deschashonly, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::ListdatastoreRequest> for requests::ListdatastoreRequest { - fn from(c: &pb::ListdatastoreRequest) -> Self { +impl From for requests::ListdatastoreRequest { + fn from(c: pb::ListdatastoreRequest) -> Self { Self { - key: Some(c.key.iter().map(|s| s.into()).collect()), // Rule #4 + key: Some(c.key.into_iter().map(|s| s.into()).collect()), // Rule #4 } } } #[allow(unused_variables)] -impl From<&pb::ListinvoicesRequest> for requests::ListinvoicesRequest { - fn from(c: &pb::ListinvoicesRequest) -> Self { +impl From for requests::ListinvoicesRequest { + fn from(c: pb::ListinvoicesRequest) -> Self { Self { - label: c.label.clone(), // Rule #1 for type string? - invstring: c.invstring.clone(), // Rule #1 for type string? - payment_hash: c.payment_hash.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? - offer_id: c.offer_id.clone(), // Rule #1 for type string? + label: c.label, // Rule #1 for type string? + invstring: c.invstring, // Rule #1 for type string? + payment_hash: c.payment_hash.map(|v| hex::encode(v)), // Rule #1 for type hex? + offer_id: c.offer_id, // Rule #1 for type string? } } } #[allow(unused_variables)] -impl From<&pb::SendonionRequest> for requests::SendonionRequest { - fn from(c: &pb::SendonionRequest) -> Self { +impl From for requests::SendonionRequest { + fn from(c: pb::SendonionRequest) -> Self { Self { onion: hex::encode(&c.onion), // Rule #1 for type hex - payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash - label: c.label.clone(), // Rule #1 for type string? - shared_secrets: Some(c.shared_secrets.iter().map(|s| s.clone().try_into().unwrap()).collect()), // Rule #4 + payment_hash: c.payment_hash.try_into().unwrap(), // Rule #1 for type hash + label: c.label, // Rule #1 for type string? + shared_secrets: Some(c.shared_secrets.into_iter().map(|s| s.try_into().unwrap()).collect()), // Rule #4 partid: c.partid.map(|v| v as u16), // Rule #1 for type u16? - bolt11: c.bolt11.clone(), // Rule #1 for type string? - amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat? - destination: c.destination.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? - localofferid: c.localofferid.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash? - groupid: c.groupid.clone(), // Rule #1 for type u64? + bolt11: c.bolt11, // Rule #1 for type string? + amount_msat: c.amount_msat.map(|a| a.into()), // Rule #1 for type msat? + destination: c.destination.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? + localofferid: c.localofferid.map(|v| v.try_into().unwrap()), // Rule #1 for type hash? + groupid: c.groupid, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::ListsendpaysRequest> for requests::ListsendpaysRequest { - fn from(c: &pb::ListsendpaysRequest) -> Self { +impl From for requests::ListsendpaysRequest { + fn from(c: pb::ListsendpaysRequest) -> Self { Self { - bolt11: c.bolt11.clone(), // Rule #1 for type string? - payment_hash: c.payment_hash.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash? + bolt11: c.bolt11, // Rule #1 for type string? + payment_hash: c.payment_hash.map(|v| v.try_into().unwrap()), // Rule #1 for type hash? status: c.status.map(|v| v.try_into().unwrap()), } } } #[allow(unused_variables)] -impl From<&pb::ListtransactionsRequest> for requests::ListtransactionsRequest { - fn from(c: &pb::ListtransactionsRequest) -> Self { +impl From for requests::ListtransactionsRequest { + fn from(c: pb::ListtransactionsRequest) -> Self { Self { } } } #[allow(unused_variables)] -impl From<&pb::PayRequest> for requests::PayRequest { - fn from(c: &pb::PayRequest) -> Self { +impl From for requests::PayRequest { + fn from(c: pb::PayRequest) -> Self { Self { - bolt11: c.bolt11.clone(), // Rule #1 for type string - amount_msat: c.amount_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat? - label: c.label.clone(), // Rule #1 for type string? - riskfactor: c.riskfactor.clone(), // Rule #1 for type number? - maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number? + bolt11: c.bolt11, // Rule #1 for type string + amount_msat: c.amount_msat.map(|a| a.into()), // Rule #1 for type msat? + label: c.label, // Rule #1 for type string? + riskfactor: c.riskfactor, // Rule #1 for type number? + maxfeepercent: c.maxfeepercent, // Rule #1 for type number? retry_for: c.retry_for.map(|v| v as u16), // Rule #1 for type u16? maxdelay: c.maxdelay.map(|v| v as u16), // Rule #1 for type u16? - exemptfee: c.exemptfee.as_ref().map(|a| a.into()), // Rule #1 for type msat? - localofferid: c.localofferid.clone().map(|v| hex::encode(v)), // Rule #1 for type hex? - exclude: Some(c.exclude.iter().map(|s| s.into()).collect()), // Rule #4 - maxfee: c.maxfee.as_ref().map(|a| a.into()), // Rule #1 for type msat? - description: c.description.clone(), // Rule #1 for type string? + exemptfee: c.exemptfee.map(|a| a.into()), // Rule #1 for type msat? + localofferid: c.localofferid.map(|v| hex::encode(v)), // Rule #1 for type hex? + exclude: Some(c.exclude.into_iter().map(|s| s.into()).collect()), // Rule #4 + maxfee: c.maxfee.map(|a| a.into()), // Rule #1 for type msat? + description: c.description, // Rule #1 for type string? } } } #[allow(unused_variables)] -impl From<&pb::ListnodesRequest> for requests::ListnodesRequest { - fn from(c: &pb::ListnodesRequest) -> Self { +impl From for requests::ListnodesRequest { + fn from(c: pb::ListnodesRequest) -> Self { Self { - id: c.id.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? + id: c.id.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? } } } #[allow(unused_variables)] -impl From<&pb::WaitanyinvoiceRequest> for requests::WaitanyinvoiceRequest { - fn from(c: &pb::WaitanyinvoiceRequest) -> Self { +impl From for requests::WaitanyinvoiceRequest { + fn from(c: pb::WaitanyinvoiceRequest) -> Self { Self { - lastpay_index: c.lastpay_index.clone(), // Rule #1 for type u64? - timeout: c.timeout.clone(), // Rule #1 for type u64? + lastpay_index: c.lastpay_index, // Rule #1 for type u64? + timeout: c.timeout, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::WaitinvoiceRequest> for requests::WaitinvoiceRequest { - fn from(c: &pb::WaitinvoiceRequest) -> Self { +impl From for requests::WaitinvoiceRequest { + fn from(c: pb::WaitinvoiceRequest) -> Self { Self { - label: c.label.clone(), // Rule #1 for type string + label: c.label, // Rule #1 for type string } } } #[allow(unused_variables)] -impl From<&pb::WaitsendpayRequest> for requests::WaitsendpayRequest { - fn from(c: &pb::WaitsendpayRequest) -> Self { +impl From for requests::WaitsendpayRequest { + fn from(c: pb::WaitsendpayRequest) -> Self { Self { - payment_hash: c.payment_hash.clone().try_into().unwrap(), // Rule #1 for type hash - timeout: c.timeout.clone(), // Rule #1 for type u32? - partid: c.partid.clone(), // Rule #1 for type u64? - groupid: c.groupid.clone(), // Rule #1 for type u64? + payment_hash: c.payment_hash.try_into().unwrap(), // Rule #1 for type hash + timeout: c.timeout, // Rule #1 for type u32? + partid: c.partid, // Rule #1 for type u64? + groupid: c.groupid, // Rule #1 for type u64? } } } #[allow(unused_variables)] -impl From<&pb::NewaddrRequest> for requests::NewaddrRequest { - fn from(c: &pb::NewaddrRequest) -> Self { +impl From for requests::NewaddrRequest { + fn from(c: pb::NewaddrRequest) -> Self { Self { addresstype: c.addresstype.map(|v| v.try_into().unwrap()), } @@ -1320,90 +1320,90 @@ impl From<&pb::NewaddrRequest> for requests::NewaddrRequest { } #[allow(unused_variables)] -impl From<&pb::WithdrawRequest> for requests::WithdrawRequest { - fn from(c: &pb::WithdrawRequest) -> Self { +impl From for requests::WithdrawRequest { + fn from(c: pb::WithdrawRequest) -> Self { Self { - destination: c.destination.clone(), // Rule #1 for type string - satoshi: c.satoshi.as_ref().map(|a| a.into()), // Rule #1 for type msat_or_all? - feerate: c.feerate.as_ref().map(|a| a.into()), // Rule #1 for type feerate? + destination: c.destination, // Rule #1 for type string + satoshi: c.satoshi.map(|a| a.into()), // Rule #1 for type msat_or_all? + feerate: c.feerate.map(|a| a.into()), // Rule #1 for type feerate? minconf: c.minconf.map(|v| v as u16), // Rule #1 for type u16? - utxos: Some(c.utxos.iter().map(|s| s.into()).collect()), // Rule #4 + utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4 } } } #[allow(unused_variables)] -impl From<&pb::KeysendRequest> for requests::KeysendRequest { - fn from(c: &pb::KeysendRequest) -> Self { +impl From for requests::KeysendRequest { + fn from(c: pb::KeysendRequest) -> Self { Self { destination: cln_rpc::primitives::Pubkey::from_slice(&c.destination).unwrap(), // Rule #1 for type pubkey - amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat - label: c.label.clone(), // Rule #1 for type string? - maxfeepercent: c.maxfeepercent.clone(), // Rule #1 for type number? - retry_for: c.retry_for.clone(), // Rule #1 for type u32? - maxdelay: c.maxdelay.clone(), // Rule #1 for type u32? - exemptfee: c.exemptfee.as_ref().map(|a| a.into()), // Rule #1 for type msat? - routehints: c.routehints.clone().map(|rl| rl.into()), // Rule #1 for type RoutehintList? + amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat + label: c.label, // Rule #1 for type string? + maxfeepercent: c.maxfeepercent, // Rule #1 for type number? + retry_for: c.retry_for, // Rule #1 for type u32? + maxdelay: c.maxdelay, // Rule #1 for type u32? + exemptfee: c.exemptfee.map(|a| a.into()), // Rule #1 for type msat? + routehints: c.routehints.map(|rl| rl.into()), // Rule #1 for type RoutehintList? } } } #[allow(unused_variables)] -impl From<&pb::FundpsbtRequest> for requests::FundpsbtRequest { - fn from(c: &pb::FundpsbtRequest) -> Self { +impl From for requests::FundpsbtRequest { + fn from(c: pb::FundpsbtRequest) -> Self { Self { - satoshi: c.satoshi.as_ref().unwrap().into(), // Rule #1 for type msat - feerate: c.feerate.as_ref().unwrap().into(), // Rule #1 for type feerate - startweight: c.startweight.clone(), // Rule #1 for type u32 - minconf: c.minconf.clone(), // Rule #1 for type u32? - reserve: c.reserve.clone(), // Rule #1 for type u32? - locktime: c.locktime.clone(), // Rule #1 for type u32? - min_witness_weight: c.min_witness_weight.clone(), // Rule #1 for type u32? - excess_as_change: c.excess_as_change.clone(), // Rule #1 for type boolean? + satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat + feerate: c.feerate.unwrap().into(), // Rule #1 for type feerate + startweight: c.startweight, // Rule #1 for type u32 + minconf: c.minconf, // Rule #1 for type u32? + reserve: c.reserve, // Rule #1 for type u32? + locktime: c.locktime, // Rule #1 for type u32? + min_witness_weight: c.min_witness_weight, // Rule #1 for type u32? + excess_as_change: c.excess_as_change, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::SendpsbtRequest> for requests::SendpsbtRequest { - fn from(c: &pb::SendpsbtRequest) -> Self { +impl From for requests::SendpsbtRequest { + fn from(c: pb::SendpsbtRequest) -> Self { Self { - psbt: c.psbt.clone(), // Rule #1 for type string - reserve: c.reserve.clone(), // Rule #1 for type boolean? + psbt: c.psbt, // Rule #1 for type string + reserve: c.reserve, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::SignpsbtRequest> for requests::SignpsbtRequest { - fn from(c: &pb::SignpsbtRequest) -> Self { +impl From for requests::SignpsbtRequest { + fn from(c: pb::SignpsbtRequest) -> Self { Self { - psbt: c.psbt.clone(), // Rule #1 for type string - signonly: Some(c.signonly.iter().map(|s| s.clone()).collect()), // Rule #4 + psbt: c.psbt, // Rule #1 for type string + signonly: Some(c.signonly.into_iter().map(|s| s).collect()), // Rule #4 } } } #[allow(unused_variables)] -impl From<&pb::UtxopsbtRequest> for requests::UtxopsbtRequest { - fn from(c: &pb::UtxopsbtRequest) -> Self { +impl From for requests::UtxopsbtRequest { + fn from(c: pb::UtxopsbtRequest) -> Self { Self { - satoshi: c.satoshi.as_ref().unwrap().into(), // Rule #1 for type msat - feerate: c.feerate.as_ref().unwrap().into(), // Rule #1 for type feerate - startweight: c.startweight.clone(), // Rule #1 for type u32 - utxos: c.utxos.iter().map(|s| s.into()).collect(), // Rule #4 - reserve: c.reserve.clone(), // Rule #1 for type u32? - reservedok: c.reservedok.clone(), // Rule #1 for type boolean? - locktime: c.locktime.clone(), // Rule #1 for type u32? - min_witness_weight: c.min_witness_weight.clone(), // Rule #1 for type u32? - excess_as_change: c.excess_as_change.clone(), // Rule #1 for type boolean? + satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat + feerate: c.feerate.unwrap().into(), // Rule #1 for type feerate + startweight: c.startweight, // Rule #1 for type u32 + utxos: c.utxos.into_iter().map(|s| s.into()).collect(), // Rule #4 + reserve: c.reserve, // Rule #1 for type u32? + reservedok: c.reservedok, // Rule #1 for type boolean? + locktime: c.locktime, // Rule #1 for type u32? + min_witness_weight: c.min_witness_weight, // Rule #1 for type u32? + excess_as_change: c.excess_as_change, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::TxdiscardRequest> for requests::TxdiscardRequest { - fn from(c: &pb::TxdiscardRequest) -> Self { +impl From for requests::TxdiscardRequest { + fn from(c: pb::TxdiscardRequest) -> Self { Self { txid: hex::encode(&c.txid), // Rule #1 for type txid } @@ -1411,20 +1411,20 @@ impl From<&pb::TxdiscardRequest> for requests::TxdiscardRequest { } #[allow(unused_variables)] -impl From<&pb::TxprepareRequest> for requests::TxprepareRequest { - fn from(c: &pb::TxprepareRequest) -> Self { +impl From for requests::TxprepareRequest { + fn from(c: pb::TxprepareRequest) -> Self { Self { - outputs: c.outputs.iter().map(|s| s.into()).collect(), // Rule #4 - feerate: c.feerate.as_ref().map(|a| a.into()), // Rule #1 for type feerate? - minconf: c.minconf.clone(), // Rule #1 for type u32? - utxos: Some(c.utxos.iter().map(|s| s.into()).collect()), // Rule #4 + outputs: c.outputs.into_iter().map(|s| s.into()).collect(), // Rule #4 + feerate: c.feerate.map(|a| a.into()), // Rule #1 for type feerate? + minconf: c.minconf, // Rule #1 for type u32? + utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4 } } } #[allow(unused_variables)] -impl From<&pb::TxsendRequest> for requests::TxsendRequest { - fn from(c: &pb::TxsendRequest) -> Self { +impl From for requests::TxsendRequest { + fn from(c: pb::TxsendRequest) -> Self { Self { txid: hex::encode(&c.txid), // Rule #1 for type txid } @@ -1432,18 +1432,18 @@ impl From<&pb::TxsendRequest> for requests::TxsendRequest { } #[allow(unused_variables)] -impl From<&pb::DisconnectRequest> for requests::DisconnectRequest { - fn from(c: &pb::DisconnectRequest) -> Self { +impl From for requests::DisconnectRequest { + fn from(c: pb::DisconnectRequest) -> Self { Self { id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey - force: c.force.clone(), // Rule #1 for type boolean? + force: c.force, // Rule #1 for type boolean? } } } #[allow(unused_variables)] -impl From<&pb::FeeratesRequest> for requests::FeeratesRequest { - fn from(c: &pb::FeeratesRequest) -> Self { +impl From for requests::FeeratesRequest { + fn from(c: pb::FeeratesRequest) -> Self { Self { style: c.style.try_into().unwrap(), } @@ -1451,86 +1451,86 @@ impl From<&pb::FeeratesRequest> for requests::FeeratesRequest { } #[allow(unused_variables)] -impl From<&pb::FundchannelRequest> for requests::FundchannelRequest { - fn from(c: &pb::FundchannelRequest) -> Self { +impl From for requests::FundchannelRequest { + fn from(c: pb::FundchannelRequest) -> Self { Self { id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey - amount: c.amount.as_ref().unwrap().into(), // Rule #1 for type msat_or_all - feerate: c.feerate.as_ref().map(|a| a.into()), // Rule #1 for type feerate? - announce: c.announce.clone(), // Rule #1 for type boolean? - minconf: c.minconf.clone(), // Rule #1 for type u32? - push_msat: c.push_msat.as_ref().map(|a| a.into()), // Rule #1 for type msat? - close_to: c.close_to.clone(), // Rule #1 for type string? - request_amt: c.request_amt.as_ref().map(|a| a.into()), // Rule #1 for type msat? - compact_lease: c.compact_lease.clone(), // Rule #1 for type string? - utxos: Some(c.utxos.iter().map(|s| s.into()).collect()), // Rule #4 - mindepth: c.mindepth.clone(), // Rule #1 for type u32? - reserve: c.reserve.as_ref().map(|a| a.into()), // Rule #1 for type msat? + amount: c.amount.unwrap().into(), // Rule #1 for type msat_or_all + feerate: c.feerate.map(|a| a.into()), // Rule #1 for type feerate? + announce: c.announce, // Rule #1 for type boolean? + minconf: c.minconf, // Rule #1 for type u32? + push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat? + close_to: c.close_to, // Rule #1 for type string? + request_amt: c.request_amt.map(|a| a.into()), // Rule #1 for type msat? + compact_lease: c.compact_lease, // Rule #1 for type string? + utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4 + mindepth: c.mindepth, // Rule #1 for type u32? + reserve: c.reserve.map(|a| a.into()), // Rule #1 for type msat? } } } #[allow(unused_variables)] -impl From<&pb::GetrouteRequest> for requests::GetrouteRequest { - fn from(c: &pb::GetrouteRequest) -> Self { +impl From for requests::GetrouteRequest { + fn from(c: pb::GetrouteRequest) -> Self { Self { id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey - amount_msat: c.amount_msat.as_ref().unwrap().into(), // Rule #1 for type msat - riskfactor: c.riskfactor.clone(), // Rule #1 for type u64 - cltv: c.cltv.clone(), // Rule #1 for type number? - fromid: c.fromid.as_ref().map(|v| cln_rpc::primitives::Pubkey::from_slice(v).unwrap()), // Rule #1 for type pubkey? - fuzzpercent: c.fuzzpercent.clone(), // Rule #1 for type u32? - exclude: Some(c.exclude.iter().map(|s| s.into()).collect()), // Rule #4 - maxhops: c.maxhops.clone(), // Rule #1 for type u32? + amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat + riskfactor: c.riskfactor, // Rule #1 for type u64 + cltv: c.cltv, // Rule #1 for type number? + fromid: c.fromid.map(|v| cln_rpc::primitives::Pubkey::from_slice(&v[..]).unwrap()), // Rule #1 for type pubkey? + fuzzpercent: c.fuzzpercent, // Rule #1 for type u32? + exclude: Some(c.exclude.into_iter().map(|s| s.into()).collect()), // Rule #4 + maxhops: c.maxhops, // Rule #1 for type u32? } } } #[allow(unused_variables)] -impl From<&pb::ListforwardsRequest> for requests::ListforwardsRequest { - fn from(c: &pb::ListforwardsRequest) -> Self { +impl From for requests::ListforwardsRequest { + fn from(c: pb::ListforwardsRequest) -> Self { Self { status: c.status.map(|v| v.try_into().unwrap()), - in_channel: c.in_channel.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? - out_channel: c.out_channel.as_ref().map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? + in_channel: c.in_channel.map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? + out_channel: c.out_channel.map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id? } } } #[allow(unused_variables)] -impl From<&pb::ListpaysRequest> for requests::ListpaysRequest { - fn from(c: &pb::ListpaysRequest) -> Self { +impl From for requests::ListpaysRequest { + fn from(c: pb::ListpaysRequest) -> Self { Self { - bolt11: c.bolt11.clone(), // Rule #1 for type string? - payment_hash: c.payment_hash.clone().map(|v| v.try_into().unwrap()), // Rule #1 for type hash? + bolt11: c.bolt11, // Rule #1 for type string? + payment_hash: c.payment_hash.map(|v| v.try_into().unwrap()), // Rule #1 for type hash? status: c.status.map(|v| v.try_into().unwrap()), } } } #[allow(unused_variables)] -impl From<&pb::PingRequest> for requests::PingRequest { - fn from(c: &pb::PingRequest) -> Self { +impl From for requests::PingRequest { + fn from(c: pb::PingRequest) -> Self { Self { id: cln_rpc::primitives::Pubkey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey - len: c.len.clone(), // Rule #1 for type number? - pongbytes: c.pongbytes.clone(), // Rule #1 for type number? + len: c.len, // Rule #1 for type number? + pongbytes: c.pongbytes, // Rule #1 for type number? } } } #[allow(unused_variables)] -impl From<&pb::SignmessageRequest> for requests::SignmessageRequest { - fn from(c: &pb::SignmessageRequest) -> Self { +impl From for requests::SignmessageRequest { + fn from(c: pb::SignmessageRequest) -> Self { Self { - message: c.message.clone(), // Rule #1 for type string + message: c.message, // Rule #1 for type string } } } #[allow(unused_variables)] -impl From<&pb::StopRequest> for requests::StopRequest { - fn from(c: &pb::StopRequest) -> Self { +impl From for requests::StopRequest { + fn from(c: pb::StopRequest) -> Self { Self { } } 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,