From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A32E61FF165 for ; Thu, 6 Nov 2025 15:47:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 256201AD5B; Thu, 6 Nov 2025 15:47:46 +0100 (CET) From: Shannon Sterz To: yew-devel@lists.proxmox.com Date: Thu, 6 Nov 2025 15:47:38 +0100 Message-ID: <20251106144740.294524-1-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762440444397 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.061 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [store.rs] Subject: [yew-devel] [PATCH yew-comp/yew-widget-toolkit v2 0/2] add helpers to get a record via a Selection from a Store X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" a very common pattern is to use a `Store` combined with a `Selection`. however, to get the record from a `Store` that has the same `Key` as is selected by the `Selection` is a little cumbersome. it requires dealing with several optional values. so many components implement a helper for that. it usually looks like this: ```rust fn get_selected_record(&self) -> Option { self.selection .selected_key() .and_then(|key| self.store.read().lookup_record(&key).cloned()) } let Some(record) = self.get_selected_record() else { return false; } ``` to avoid duplicating this effort in every such component add new helper methods to the `Store`. they each take a `Selection` and either return an optional reference or an optional clone of the selected record. turning the above into: ```rust let Some(record) = self.store.selected_record(&self.selection) else { return false; } ``` there are also helpers that are prefixed with `multi_` to help deal with `Selection`s in multi-select mode by returning a vector of all selected entries. the second commit in this series is mostly for demonstrative purposes. sending this as an rfc as i am not sure if the naming of these functions is ideal or whether we want to add both helpers (instead of just one of them). proxmox-yew-widget-toolkit: Shannon Sterz (1): store: add helper methods to extract a record via a selection src/state/store.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) proxmox-yew-comp: Shannon Sterz (1): token panel: use new `selected_record` helper src/token_panel.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) Summary over all repositories: 2 files changed, 50 insertions(+), 10 deletions(-) -- Generated by git-murpp 0.8.1 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel