On Thu, Jun 26, 2025 at 12:36:23PM +0200, Benno Lossin wrote: > Or, we could change `Release` to be: > > pub trait Release { > type Ptr: ForeignOwnable; > > fn release(this: Self::Ptr); > } > > and then `register_release` is: > > pub fn register_release<T: Release>(dev: &Device<Bound>, data: T::Ptr) -> Result > > This way, one can store a `Box<T>` and get access to the `T` at the end. I think this was also the case before? Well, it was P::Borrowed instead. > Or if they store the value in an `Arc<T>`, they have the option to clone > it and give it to somewhere else. Anyways, I really like this proposal of implementing the Release trait. > Related questions: > > * should we implement `ForeignOwnable` for `&'static T`? There's already a patch on the list doing this in the context of DebugFS [1]. [1] https://lore.kernel.org/lkml/20250624-debugfs-rust-v7-3-9c8835a7a20f@xxxxxxxxxx/ > * should we require `'static` in `ForeignOwnable`? At the moment we only > have those kinds supported and it only makes sense, a foreign owned > object can be owned for any amount of time (so it must stay valid > indefinitely). Sounds reasonable to me.