From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v4 6/8] tui: change get_value return type for easier error handling
Date: Fri, 11 Jul 2025 18:27:09 +0200 [thread overview]
Message-ID: <20250711162711.133248-8-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20250711162711.133248-1-m.koeppl@proxmox.com>
Adapt the return type of CidrAddressEditView's get_value implementation
for the FormViewGetValue trait to handle errors in case of invalid CIDR
similarly to other (parsing) errors done in the TUIs network dialog.
Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
proxmox-tui-installer/src/main.rs | 8 +++++---
proxmox-tui-installer/src/views/mod.rs | 9 +++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs
index 57a334f..15ee5d3 100644
--- a/proxmox-tui-installer/src/main.rs
+++ b/proxmox-tui-installer/src/main.rs
@@ -20,9 +20,8 @@ use proxmox_installer_common::{
ROOT_PASSWORD_MIN_LENGTH,
options::{BootdiskOptions, NetworkOptions, TimezoneOptions, email_validate},
setup::{LocaleInfo, ProxmoxProduct, RuntimeInfo, SetupInfo, installer_setup},
- utils::Fqdn,
+ utils::{CidrAddress, Fqdn},
};
-
mod setup;
mod system;
@@ -536,7 +535,10 @@ fn network_dialog(siv: &mut Cursive) -> InstallerView {
let address = view
.get_value::<CidrAddressEditView, _>(2)
- .ok_or("failed to retrieve host address")?;
+ .ok_or("failed to retrieve host address".to_string())
+ .and_then(|(ip_addr, mask)| {
+ CidrAddress::new(ip_addr, mask).map_err(|err| err.to_string())
+ })?;
let gateway = view
.get_value::<EditView, _>(3)
diff --git a/proxmox-tui-installer/src/views/mod.rs b/proxmox-tui-installer/src/views/mod.rs
index 4364489..537e3ed 100644
--- a/proxmox-tui-installer/src/views/mod.rs
+++ b/proxmox-tui-installer/src/views/mod.rs
@@ -387,8 +387,9 @@ where
}
}
-impl FormViewGetValue<CidrAddress> for CidrAddressEditView {
- fn get_value(&self) -> Option<CidrAddress> {
+impl FormViewGetValue<(IpAddr, usize)> for CidrAddressEditView {
+ // FIXME: return CidrAddress (again) with proper error handling through Result
+ fn get_value(&self) -> Option<(IpAddr, usize)> {
self.get_values()
}
}
@@ -569,7 +570,7 @@ impl CidrAddressEditView {
.fixed_width(4)
}
- fn get_values(&self) -> Option<CidrAddress> {
+ fn get_values(&self) -> Option<(IpAddr, usize)> {
let addr = self
.view
.get_child(0)?
@@ -587,7 +588,7 @@ impl CidrAddressEditView {
.get_content()
.ok()?;
- CidrAddress::new(addr, mask).ok()
+ Some((addr, mask))
}
}
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-07-11 16:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 16:27 [pve-devel] [PATCH docs/installer v4 0/9] add early disk and network sanity checks Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH docs v4 1/1] installation: remove maxroot size requirement and mention default instead Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 1/8] auto: add early answer file sanity check for RAID configurations Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 2/8] move RAID setup checks to RAID level enum implementations Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 3/8] close #5887: add sanity check for LVM swapsize Michael Köppl
2025-07-11 17:54 ` Thomas Lamprecht
2025-07-15 9:43 ` Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 4/8] auto: add check for duplicate disks in answer file Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 5/8] common: add more descriptive errors for invalid network configs Michael Köppl
2025-07-11 16:27 ` Michael Köppl [this message]
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 7/8] common: add checks for valid subnet mask and IPv4 address within subnet Michael Köppl
2025-07-11 16:27 ` [pve-devel] [PATCH installer v4 8/8] tui, gui: streamline error messages around disk and RAID checks Michael Köppl
2025-07-15 9:50 ` [pve-devel] superseded: [PATCH docs/installer v4 0/9] add early disk and network sanity checks Michael Köppl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250711162711.133248-8-m.koeppl@proxmox.com \
--to=m.koeppl@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.