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: <07575756-58EA-4245-B837-AEC4DDCD0DB5@collabora.com>
Date: Wed, 30 Jul 2025 09:59:24 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Benno Lossin <lossin@...nel.org>
Cc: Daniel Sedlak <daniel@...lak.dev>,
 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

[…]

> 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.

— Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ