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 657921FF16B for ; Fri, 21 Nov 2025 17:14:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2385D27470; Fri, 21 Nov 2025 17:14:28 +0100 (CET) From: Shannon Sterz To: yew-devel@lists.proxmox.com Date: Fri, 21 Nov 2025 17:14:21 +0100 Message-ID: <20251121161423.390869-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: 1763741632521 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.079 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-comp/yew-widget-toolkit v3 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). Changelog --------- changes since v2: * rebase on current master. changes since v1: * rebase on current master. * add helpers for multi selections too. 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 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) Summary over all repositories: 2 files changed, 50 insertions(+), 9 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