gst::DateTime construction in Rust

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gst::DateTime construction in Rust

Russel Winder
Is there a simple way of constructing a gst::DateTime from a *mut GstDateTime?
I feel there must be, but there doesn't seem to be anything straightforward
from looking at the manual. The clear hypothesis is that I have missed
something – which is what I am hoping is the case.

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gst::DateTime construction in Rust

Sebastian Dröge-3
On Sun, 2019-05-19 at 18:26 +0100, Russel Winder wrote:
> Is there a simple way of constructing a gst::DateTime from a *mut GstDateTime?
> I feel there must be, but there doesn't seem to be anything straightforward
> from looking at the manual. The clear hypothesis is that I have missed
> something – which is what I am hoping is the case.

glib::translate has all the generic FFI/Rust translation infrastructure
that you can use for such things.

Depending on the ownership semantics, you want from_glib_none() for
transfer none or from_glib_full() for transfer full here.

--
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gst::DateTime construction in Rust

Russel Winder
On Mon, 2019-05-20 at 09:01 +0300, Sebastian Dröge wrote:
>
[…]
> glib::translate has all the generic FFI/Rust translation infrastructure
> that you can use for such things.

I have been trying to read:

https://people.gnome.org/~federico/blog/how-glib-rs-works-part-1.html

and the following two pieces (it seems there were going to be more but they
didn't appear) to try and understand the Rust GLib stuff, but I have to admit,
I am failing so far, hence the earlier email. I shall persist though as I want
to know this stuff.

> Depending on the ownership semantics, you want from_glib_none() for
> transfer none or from_glib_full() for transfer full here.

I am guessing that one has to read the C API documents to determine whether to
use "none" or "full" for the functions of the API in Rust. However the current
problem is dealing with data structures directly so I am guessing use "none".
In C/C++ it was a question of using the gst_date_time_ref function, I am
assuming this is effectively what happens when using from_glib_none?

--
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gst::DateTime construction in Rust

Sebastian Dröge-3
On Mon, 2019-05-20 at 08:45 +0100, Russel Winder wrote:
>
> > Depending on the ownership semantics, you want from_glib_none() for
> > transfer none or from_glib_full() for transfer full here.
>
> I am guessing that one has to read the C API documents to determine whether to
> use "none" or "full" for the functions of the API in Rust. However the current
> problem is dealing with data structures directly so I am guessing use "none".

It depends on whether you can borrow the struct field directly or need
to return a new reference. That's something for which you need to
understand how the C API in question works.

One of the things where Rust moves things that are hopefully mentioned
in the documentation to the language.

> In C/C++ it was a question of using the gst_date_time_ref function, I am
> assuming this is effectively what happens when using from_glib_none?

Yes, that's correct.

--
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (981 bytes) Download Attachment