pub struct NativeHandle { /* private fields */ }Expand description
An opaque platform GPU buffer a NativeImporter turns into a texture.
The bus never dereferences the pointer; only the importer installed for its kind does. The frame’s producer owns the buffer’s lifetime and drops its own reference in the frame’s release callback.
The fields are private and the only constructor is the unsafe
Self::new: an importer dereferences the pointer on that constructor’s
contract alone, so safe code cannot hand the bus a forged one.
A handle is move-only — neither Clone nor Copy — so it cannot be
copied, and a frame’s payload and release callback are private to the
frame: outside unsafe, a handle cannot leave the frame that carries its
release (see SourceFrame::into_parts).
Implementations§
Source§impl NativeHandle
impl NativeHandle
Sourcepub unsafe fn new(kind: NativeHandleKind, ptr: *mut c_void) -> NativeHandle
pub unsafe fn new(kind: NativeHandleKind, ptr: *mut c_void) -> NativeHandle
Wraps ptr, a platform object of kind, for a
SourcePayload::Native frame.
§Safety
ptr is a live platform object of exactly kind — a
CVPixelBufferRef for NativeHandleKind::CvPixelBuffer, an
AHardwareBuffer* for NativeHandleKind::AHardwareBuffer — on which
the producer holds a retained reference of its own (CFRetain,
AHardwareBuffer_acquire), kept until the release callback of the one
frame this handle is placed in has run (the handle is move-only, so it
cannot be copied, and outside unsafe it cannot leave that frame
without the callback). The NativeImporter installed
for kind dereferences the pointer (describes, imports and retains the
object) on this promise alone, so a dangling, foreign or mistyped
pointer is undefined behaviour there. A bridge from the plugin
substrate’s own handle forwards that handle’s identical contract.
Sourcepub fn kind(&self) -> NativeHandleKind
pub fn kind(&self) -> NativeHandleKind
The platform object Self::ptr points at.
Trait Implementations§
Source§impl Debug for NativeHandle
impl Debug for NativeHandle
impl Eq for NativeHandle
Source§impl PartialEq for NativeHandle
impl PartialEq for NativeHandle
impl Send for NativeHandle
impl StructuralPartialEq for NativeHandle
Auto Trait Implementations§
impl !Sync for NativeHandle
impl Freeze for NativeHandle
impl RefUnwindSafe for NativeHandle
impl Unpin for NativeHandle
impl UnsafeUnpin for NativeHandle
impl UnwindSafe for NativeHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.