Skip to content

Commit 31fdc86

Browse files
committed
Move v25 wallet to subdirectory
Move wallet.rs to ./wallet/mod.rs Split out the into_model() into an into module. Code move only.
1 parent 1824ca3 commit 31fdc86

File tree

2 files changed

+37
-32
lines changed

2 files changed

+37
-32
lines changed

types/src/v25/wallet/into.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
use super::{CreateWallet, LoadWallet, UnloadWallet};
4+
use crate::model;
5+
6+
impl CreateWallet {
7+
/// Converts version specific type to a version nonspecific, more strongly typed type.
8+
pub fn into_model(self) -> model::CreateWallet {
9+
// As the content of the deprecated `warning` field would be the same as `warnings`, we
10+
// simply ignore the field, even in case it's set.
11+
model::CreateWallet { name: self.name, warnings: self.warnings.unwrap_or_default() }
12+
}
13+
14+
/// Returns the created wallet name.
15+
pub fn name(self) -> String { self.into_model().name }
16+
}
17+
18+
impl LoadWallet {
19+
/// Converts version specific type to a version nonspecific, more strongly typed type.
20+
pub fn into_model(self) -> model::LoadWallet {
21+
// As the content of the deprecated `warning` field would be the same as `warnings`, we
22+
// simply ignore the field, even in case it's set.
23+
model::LoadWallet { name: self.name, warnings: self.warnings.unwrap_or_default() }
24+
}
25+
26+
/// Returns the loaded wallet name.
27+
pub fn name(self) -> String { self.into_model().name }
28+
}
29+
30+
impl UnloadWallet {
31+
/// Converts version specific type to a version nonspecific, more strongly typed type.
32+
pub fn into_model(self) -> model::UnloadWallet {
33+
model::UnloadWallet { warnings: self.warnings.unwrap_or_default() }
34+
}
35+
}

types/src/v25/wallet.rs renamed to types/src/v25/wallet/mod.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//!
55
//! Types for methods found under the `== Wallet ==` section of the API docs.
66
7-
use serde::{Deserialize, Serialize};
7+
mod into;
88

9-
use crate::model;
9+
use serde::{Deserialize, Serialize};
1010

1111
/// Result of the JSON-RPC method `createwallet`.
1212
///
@@ -39,17 +39,6 @@ pub struct CreateWallet {
3939
pub warnings: Option<Vec<String>>,
4040
}
4141

42-
impl CreateWallet {
43-
/// Converts version specific type to a version nonspecific, more strongly typed type.
44-
pub fn into_model(self) -> model::CreateWallet {
45-
// As the content of the deprecated `warning` field would be the same as `warnings`, we
46-
// simply ignore the field, even in case it's set.
47-
model::CreateWallet { name: self.name, warnings: self.warnings.unwrap_or_default() }
48-
}
49-
50-
/// Returns the created wallet name.
51-
pub fn name(self) -> String { self.into_model().name }
52-
}
5342
/// Result of JSON-RPC method `listdescriptors`.
5443
///
5544
/// > List descriptors imported into a descriptor-enabled wallet.
@@ -108,18 +97,6 @@ pub struct LoadWallet {
10897
pub warnings: Option<Vec<String>>,
10998
}
11099

111-
impl LoadWallet {
112-
/// Converts version specific type to a version nonspecific, more strongly typed type.
113-
pub fn into_model(self) -> model::LoadWallet {
114-
// As the content of the deprecated `warning` field would be the same as `warnings`, we
115-
// simply ignore the field, even in case it's set.
116-
model::LoadWallet { name: self.name, warnings: self.warnings.unwrap_or_default() }
117-
}
118-
119-
/// Returns the loaded wallet name.
120-
pub fn name(self) -> String { self.into_model().name }
121-
}
122-
123100
/// Result of the JSON-RPC method `unloadwallet`.
124101
///
125102
/// > unloadwallet ( "wallet_name" load_on_startup )
@@ -141,10 +118,3 @@ pub struct UnloadWallet {
141118
/// Warning messages, if any, related to loading the wallet.
142119
pub warnings: Option<Vec<String>>,
143120
}
144-
145-
impl UnloadWallet {
146-
/// Converts version specific type to a version nonspecific, more strongly typed type.
147-
pub fn into_model(self) -> model::UnloadWallet {
148-
model::UnloadWallet { warnings: self.warnings.unwrap_or_default() }
149-
}
150-
}

0 commit comments

Comments
 (0)