On Mon, 1 Jul 2024 at 11:02, Paolo Bonzini <pbonz...@redhat.com> wrote:
> +/// A type for which there is a canonical representation as a C datum.
> +pub trait CloneToForeign {
> +    /// The representation of `Self` as a C datum.  Typically a
> +    /// `struct`, though there are exceptions for example `c_char`
> +    /// for strings, since C strings are of `char *` type).
> +    type Foreign;
> +
> +    /// Free the C datum pointed to by `p`.
> +    ///
> +    /// # Safety
> +    ///
> +    /// `p` must be `NULL` or point to valid data.
> +    unsafe fn free_foreign(p: *mut Self::Foreign);
> +
> +    /// Convert a native Rust object to a foreign C struct, copying
> +    /// everything pointed to by `self` (same as `to_glib_full` in `glib-rs`)
> +    fn clone_to_foreign(&self) -> OwnedPointer<Self>;

I expected the return type to be OwnedPointer<Self::Foreign>. Is this a typo?

Also, why is the return type OwnedPointer<T> instead of just T? I
guess it's common to want a heap-allocated value here so you decided
to hard-code OwnedPointer<>, but I'm not sure.

Reply via email to