Skip to content

Commit d9aa818

Browse files
committed
Format payjoin-ffi
Enforce the same formatting rules as the rest of rust-payjoin. This was done by removing the custom `rust-toolchain.toml` and `rustfmt.toml` then applying the formatting with `cargo fmt`.
1 parent e9b3a40 commit d9aa818

File tree

15 files changed

+120
-430
lines changed

15 files changed

+120
-430
lines changed

payjoin-ffi/rust-toolchain.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

payjoin-ffi/rustfmt.toml

Lines changed: 0 additions & 77 deletions
This file was deleted.

payjoin-ffi/src/error.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
pub struct ImplementationError(#[from] payjoin::ImplementationError);
88

99
impl From<String> for ImplementationError {
10-
fn from(value: String) -> Self {
11-
Self(value.into())
12-
}
10+
fn from(value: String) -> Self { Self(value.into()) }
1311
}
1412

1513
#[derive(Debug, thiserror::Error)]

payjoin-ffi/src/io.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ pub mod error {
1010
message: String,
1111
}
1212
impl From<payjoin::io::Error> for IoError {
13-
fn from(value: payjoin::io::Error) -> Self {
14-
IoError { message: format!("{value:?}") }
15-
}
13+
fn from(value: payjoin::io::Error) -> Self { IoError { message: format!("{value:?}") } }
1614
}
1715
}
1816

payjoin-ffi/src/ohttp.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,18 @@ pub mod error {
88
message: String,
99
}
1010
impl From<ohttp::Error> for OhttpError {
11-
fn from(value: ohttp::Error) -> Self {
12-
OhttpError { message: format!("{value:?}") }
13-
}
11+
fn from(value: ohttp::Error) -> Self { OhttpError { message: format!("{value:?}") } }
1412
}
1513
impl From<String> for OhttpError {
16-
fn from(value: String) -> Self {
17-
OhttpError { message: value }
18-
}
14+
fn from(value: String) -> Self { OhttpError { message: value } }
1915
}
2016
}
2117

2218
impl From<payjoin::OhttpKeys> for OhttpKeys {
23-
fn from(value: payjoin::OhttpKeys) -> Self {
24-
Self(value)
25-
}
19+
fn from(value: payjoin::OhttpKeys) -> Self { Self(value) }
2620
}
2721
impl From<OhttpKeys> for payjoin::OhttpKeys {
28-
fn from(value: OhttpKeys) -> Self {
29-
value.0
30-
}
22+
fn from(value: OhttpKeys) -> Self { value.0 }
3123
}
3224
#[cfg_attr(feature = "uniffi", derive(uniffi::Object))]
3325
#[derive(Debug, Clone)]
@@ -64,7 +56,5 @@ impl From<&ClientResponse> for ohttp::ClientResponse {
6456
}
6557

6658
impl From<ohttp::ClientResponse> for ClientResponse {
67-
fn from(value: ohttp::ClientResponse) -> Self {
68-
Self(Mutex::new(Some(value)))
69-
}
59+
fn from(value: ohttp::ClientResponse) -> Self { Self(Mutex::new(Some(value))) }
7060
}

payjoin-ffi/src/receive/error.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@ pub struct ReplyableError(#[from] receive::ReplyableError);
5656
pub struct JsonReply(receive::JsonReply);
5757

5858
impl From<JsonReply> for receive::JsonReply {
59-
fn from(value: JsonReply) -> Self {
60-
value.0
61-
}
59+
fn from(value: JsonReply) -> Self { value.0 }
6260
}
6361

6462
impl From<ReplyableError> for JsonReply {
65-
fn from(value: ReplyableError) -> Self {
66-
Self(value.0.into())
67-
}
63+
fn from(value: ReplyableError) -> Self { Self(value.0.into()) }
6864
}
6965

7066
/// Error that may occur during a v2 session typestate change

payjoin-ffi/src/receive/mod.rs

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ pub mod uni;
2424
pub struct NewReceiver(payjoin::receive::v2::NewReceiver);
2525

2626
impl From<NewReceiver> for payjoin::receive::v2::NewReceiver {
27-
fn from(value: NewReceiver) -> Self {
28-
value.0
29-
}
27+
fn from(value: NewReceiver) -> Self { value.0 }
3028
}
3129

3230
impl From<payjoin::receive::v2::NewReceiver> for NewReceiver {
33-
fn from(value: payjoin::receive::v2::NewReceiver) -> Self {
34-
Self(value)
35-
}
31+
fn from(value: payjoin::receive::v2::NewReceiver) -> Self { Self(value) }
3632
}
3733

3834
impl NewReceiver {
@@ -78,15 +74,11 @@ impl NewReceiver {
7874
pub struct Receiver(payjoin::receive::v2::Receiver);
7975

8076
impl From<Receiver> for payjoin::receive::v2::Receiver {
81-
fn from(value: Receiver) -> Self {
82-
value.0
83-
}
77+
fn from(value: Receiver) -> Self { value.0 }
8478
}
8579

8680
impl From<payjoin::receive::v2::Receiver> for Receiver {
87-
fn from(value: payjoin::receive::v2::Receiver) -> Self {
88-
Self(value)
89-
}
81+
fn from(value: payjoin::receive::v2::Receiver) -> Self { Self(value) }
9082
}
9183

9284
impl Receiver {
@@ -138,24 +130,18 @@ impl Receiver {
138130
.map(Into::into)
139131
}
140132

141-
pub fn key(&self) -> ReceiverToken {
142-
self.0.key()
143-
}
133+
pub fn key(&self) -> ReceiverToken { self.0.key() }
144134
}
145135

146136
#[derive(Clone)]
147137
pub struct UncheckedProposal(payjoin::receive::v2::UncheckedProposal);
148138

149139
impl From<payjoin::receive::v2::UncheckedProposal> for UncheckedProposal {
150-
fn from(value: payjoin::receive::v2::UncheckedProposal) -> Self {
151-
Self(value)
152-
}
140+
fn from(value: payjoin::receive::v2::UncheckedProposal) -> Self { Self(value) }
153141
}
154142

155143
impl From<UncheckedProposal> for payjoin::receive::v2::UncheckedProposal {
156-
fn from(value: UncheckedProposal) -> Self {
157-
value.0
158-
}
144+
fn from(value: UncheckedProposal) -> Self { value.0 }
159145
}
160146

161147
impl UncheckedProposal {
@@ -220,9 +206,7 @@ impl UncheckedProposal {
220206
pub struct MaybeInputsOwned(payjoin::receive::v2::MaybeInputsOwned);
221207

222208
impl From<payjoin::receive::v2::MaybeInputsOwned> for MaybeInputsOwned {
223-
fn from(value: payjoin::receive::v2::MaybeInputsOwned) -> Self {
224-
Self(value)
225-
}
209+
fn from(value: payjoin::receive::v2::MaybeInputsOwned) -> Self { Self(value) }
226210
}
227211

228212
impl MaybeInputsOwned {
@@ -242,9 +226,7 @@ impl MaybeInputsOwned {
242226
pub struct MaybeInputsSeen(payjoin::receive::v2::MaybeInputsSeen);
243227

244228
impl From<payjoin::receive::v2::MaybeInputsSeen> for MaybeInputsSeen {
245-
fn from(value: payjoin::receive::v2::MaybeInputsSeen) -> Self {
246-
Self(value)
247-
}
229+
fn from(value: payjoin::receive::v2::MaybeInputsSeen) -> Self { Self(value) }
248230
}
249231

250232
impl MaybeInputsSeen {
@@ -268,9 +250,7 @@ impl MaybeInputsSeen {
268250
pub struct OutputsUnknown(payjoin::receive::v2::OutputsUnknown);
269251

270252
impl From<payjoin::receive::v2::OutputsUnknown> for OutputsUnknown {
271-
fn from(value: payjoin::receive::v2::OutputsUnknown) -> Self {
272-
Self(value)
273-
}
253+
fn from(value: payjoin::receive::v2::OutputsUnknown) -> Self { Self(value) }
274254
}
275255

276256
impl OutputsUnknown {
@@ -290,15 +270,11 @@ impl OutputsUnknown {
290270
pub struct WantsOutputs(payjoin::receive::v2::WantsOutputs);
291271

292272
impl From<payjoin::receive::v2::WantsOutputs> for WantsOutputs {
293-
fn from(value: payjoin::receive::v2::WantsOutputs) -> Self {
294-
Self(value)
295-
}
273+
fn from(value: payjoin::receive::v2::WantsOutputs) -> Self { Self(value) }
296274
}
297275

298276
impl WantsOutputs {
299-
pub fn output_substitution(&self) -> OutputSubstitution {
300-
self.0.output_substitution()
301-
}
277+
pub fn output_substitution(&self) -> OutputSubstitution { self.0.output_substitution() }
302278

303279
pub fn replace_receiver_outputs(
304280
&self,
@@ -325,17 +301,13 @@ impl WantsOutputs {
325301
.map_err(Into::into)
326302
}
327303

328-
pub fn commit_outputs(&self) -> WantsInputs {
329-
self.0.clone().commit_outputs().into()
330-
}
304+
pub fn commit_outputs(&self) -> WantsInputs { self.0.clone().commit_outputs().into() }
331305
}
332306

333307
pub struct WantsInputs(payjoin::receive::v2::WantsInputs);
334308

335309
impl From<payjoin::receive::v2::WantsInputs> for WantsInputs {
336-
fn from(value: payjoin::receive::v2::WantsInputs) -> Self {
337-
Self(value)
338-
}
310+
fn from(value: payjoin::receive::v2::WantsInputs) -> Self { Self(value) }
339311
}
340312
impl WantsInputs {
341313
/// Select receiver input such that the payjoin avoids surveillance.
@@ -370,9 +342,7 @@ impl WantsInputs {
370342
.map_err(Into::into)
371343
}
372344

373-
pub fn commit_inputs(&self) -> ProvisionalProposal {
374-
self.0.clone().commit_inputs().into()
375-
}
345+
pub fn commit_inputs(&self) -> ProvisionalProposal { self.0.clone().commit_inputs().into() }
376346
}
377347

378348
#[derive(Debug, Clone)]
@@ -391,23 +361,17 @@ impl InputPair {
391361
}
392362

393363
impl From<InputPair> for payjoin::receive::InputPair {
394-
fn from(value: InputPair) -> Self {
395-
value.0
396-
}
364+
fn from(value: InputPair) -> Self { value.0 }
397365
}
398366

399367
impl From<payjoin::receive::InputPair> for InputPair {
400-
fn from(value: payjoin::receive::InputPair) -> Self {
401-
Self(value)
402-
}
368+
fn from(value: payjoin::receive::InputPair) -> Self { Self(value) }
403369
}
404370

405371
pub struct ProvisionalProposal(pub payjoin::receive::v2::ProvisionalProposal);
406372

407373
impl From<payjoin::receive::v2::ProvisionalProposal> for ProvisionalProposal {
408-
fn from(value: payjoin::receive::v2::ProvisionalProposal) -> Self {
409-
Self(value)
410-
}
374+
fn from(value: payjoin::receive::v2::ProvisionalProposal) -> Self { Self(value) }
411375
}
412376

413377
impl ProvisionalProposal {
@@ -436,15 +400,11 @@ impl ProvisionalProposal {
436400
pub struct PayjoinProposal(pub payjoin::receive::v2::PayjoinProposal);
437401

438402
impl From<PayjoinProposal> for payjoin::receive::v2::PayjoinProposal {
439-
fn from(value: PayjoinProposal) -> Self {
440-
value.0
441-
}
403+
fn from(value: PayjoinProposal) -> Self { value.0 }
442404
}
443405

444406
impl From<payjoin::receive::v2::PayjoinProposal> for PayjoinProposal {
445-
fn from(value: payjoin::receive::v2::PayjoinProposal) -> Self {
446-
Self(value)
447-
}
407+
fn from(value: payjoin::receive::v2::PayjoinProposal) -> Self { Self(value) }
448408
}
449409

450410
impl PayjoinProposal {

0 commit comments

Comments
 (0)