Skip to content

Commit f381fab

Browse files
rename ffi_import_labels, drop map(drop), extract is_supported
1 parent 1b47d11 commit f381fab

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

rust/src/backup/import.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ pub(crate) fn cleanup_failed_wallet(metadata: &WalletMetadata) -> Vec<String> {
524524

525525
fn import_labels(id: &WalletId, jsonl: &str) -> Result<(), BackupError> {
526526
let manager = LabelManager::new(id.clone());
527-
manager.import(jsonl).map(drop).map_err(|e| BackupError::Restore(e.to_string()))
527+
manager.import(jsonl).map_err(|e| BackupError::Restore(e.to_string()))?;
528+
Ok(())
528529
}
529530

530531
pub(crate) fn restore_wallet_labels(
@@ -542,8 +543,8 @@ pub(crate) fn restore_wallet_labels(
542543
LabelRestoreBehavior::MarkCloudBackupDirty => import_labels(wallet_id, jsonl),
543544
LabelRestoreBehavior::PreserveCloudBackupClean => manager
544545
.import_without_cloud_backup_dirty(jsonl)
545-
.map(drop)
546-
.map_err(|error| BackupError::Restore(error.to_string())),
546+
.map_err(|error| BackupError::Restore(error.to_string()))
547+
.map(|_| ()),
547548
};
548549

549550
match import_result {

rust/src/label_manager.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl LabelManager {
238238
}
239239

240240
#[uniffi::method(name = "importLabels")]
241-
pub fn _import_labels(
241+
pub fn ffi_import_labels(
242242
&self,
243243
labels: Arc<Bip329Labels>,
244244
) -> Result<LabelParseReport, LabelManagerError> {
@@ -315,17 +315,15 @@ impl LabelManager {
315315
labels: impl Into<Labels>,
316316
) -> Result<LabelParseReport, LabelManagerError> {
317317
let labels = labels.into();
318-
// Count only supported variants — insert_label_with_write_txn silently drops
318+
// count only supported variants — insert_label_with_write_txn silently drops
319319
// PublicKey and ExtendedPublicKey, so labels.len() would overstate the import count.
320-
let supported = labels
321-
.iter()
322-
.filter(|l| {
323-
matches!(
324-
l,
325-
Label::Transaction(_) | Label::Address(_) | Label::Input(_) | Label::Output(_)
326-
)
327-
})
328-
.count() as u32;
320+
let is_supported = |l: &&Label| {
321+
matches!(
322+
l,
323+
Label::Transaction(_) | Label::Address(_) | Label::Input(_) | Label::Output(_)
324+
)
325+
};
326+
let supported = labels.iter().filter(is_supported).count() as u32;
329327
let skipped = labels.len() as u32 - supported;
330328
let report = LabelParseReport { imported: supported, skipped };
331329
self.save_imported_labels(labels, report, true)

0 commit comments

Comments
 (0)