allocator: Add a method to retrieve the name of the allocated memory type

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1655>
This commit is contained in:
Thibault Saunier 2025-02-18 17:00:13 -03:00 committed by Backport Bot
parent 3f220ce5d9
commit d2a59304b4

View file

@ -5,6 +5,11 @@ use glib::{prelude::*, translate::*};
use crate::{ffi, Allocator};
impl Allocator {
pub fn memory_type(&self) -> &'static glib::GStr {
let obj: *const ffi::GstAllocator = self.to_glib_none().0;
unsafe { glib::GStr::from_ptr((*obj).mem_type) }
}
#[doc(alias = "gst_allocator_register")]
pub fn register(name: &str, allocator: impl IsA<Allocator>) {
skip_assert_initialized!();