Re: [PATCH 1/6] rust: types: Add Ownable/Owned types

From: Andreas Hindborg
Date: Wed Feb 19 2025 - 03:50:26 EST


"Asahi Lina" <lina@xxxxxxxxxxxxx> writes:

> By analogy to AlwaysRefCounted and ARef, an Ownable type is a (typically
> C FFI) type that *may* be owned by Rust, but need not be. Unlike
> AlwaysRefCounted, this mechanism expects the reference to be unique
> within Rust, and does not allow cloning.
>
> Conceptually, this is similar to a KBox<T>, except that it delegates
> resource management to the T instead of using a generic allocator.
>
> Signed-off-by: Asahi Lina <lina@xxxxxxxxxxxxx>

Over all looks good to me - I agree with the points already discussed.

Could you put it in a separate module and file? `kernel::types::ownable`
and then `pub use` in `types.rs`. `types.rs` is getting quite busy.


Best regards,
Andreas Hindborg