lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <01963F16-1956-4474-AF8D-68E9C5CB45BF@collabora.com>
Date: Wed, 30 Jul 2025 10:30:12 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Daniel Sedlak <daniel@...lak.dev>
Cc: Benno Lossin <lossin@...nel.org>,
 Michael Turquette <mturquette@...libre.com>,
 Stephen Boyd <sboyd@...nel.org>,
 Miguel Ojeda <ojeda@...nel.org>,
 Alex Gaynor <alex.gaynor@...il.com>,
 Boqun Feng <boqun.feng@...il.com>,
 Gary Guo <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>,
 Andreas Hindborg <a.hindborg@...nel.org>,
 Alice Ryhl <aliceryhl@...gle.com>,
 Trevor Gross <tmgross@...ch.edu>,
 Danilo Krummrich <dakr@...nel.org>,
 "Rafael J. Wysocki" <rafael@...nel.org>,
 Viresh Kumar <viresh.kumar@...aro.org>,
 Alexandre Courbot <acourbot@...dia.com>,
 linux-clk@...r.kernel.org,
 rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org,
 linux-pm@...r.kernel.org
Subject: Re: [PATCH] rust: clk: use the type-state pattern



> On 30 Jul 2025, at 10:27, Daniel Sedlak <daniel@...lak.dev> wrote:
> 
> 
> On 7/30/25 2:59 PM, Daniel Almeida wrote:
>> […]
>>> We essentially would like to have a `#[sealed]` attribute that we can
>>> put on a trait to avoid the `mod private { pub trait Sealed }` dance.
>>> (so a trait that cannot be implemented outside of the module declaring
>>> it)
>>> 
>>> ---
>>> Cheers,
>>> Benno
>> This is not exactly what you said, but how about a declarative macro? e.g.:
>> macro_rules! sealed {
>>     ($($ty:ident),* $(,)?) => {
>>         mod private {
>>             pub trait Sealed {}
>>             $(impl Sealed for super::$ty {})*
>>         }
>>         use private::Sealed;
>>     };
>> }
>> sealed!(Unprepared, Prepared, Enabled)
>> Note that I am just brainstorming the general idea here, I did not test it yet.
> 
> I think that API-wise it would be better to have a proc-macro #[sealed], something similar to [1], as it may provide better error messages, when used incorrectly. So the outcome could look like.
> 
> #[sealed]
> pub trait ClkState {
> …
> }
> 
> And then
> 
> #[sealed]
> impl ClkState for XXX {
> …
> }
> 
> If you are interested, I can try to look into that.
> 
> Link: https://crates.io/crates/sealed [1]
> 
> Thanks!
> Daniel

If you have the bandwidth, that would be nice indeed! :)

— Daniel





Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ