vapoursynth/plugins/
frame_context.rs

1use std::marker::PhantomData;
2use std::ptr::NonNull;
3use vapoursynth_sys as ffi;
4
5/// A frame context used in filters.
6#[derive(Debug, Clone, Copy)]
7pub struct FrameContext<'a> {
8    handle: NonNull<ffi::VSFrameContext>,
9    _owner: PhantomData<&'a ()>,
10}
11
12impl<'a> FrameContext<'a> {
13    /// Wraps `handle` in a `FrameContext`.
14    ///
15    /// # Safety
16    /// The caller must ensure `handle` is valid and API is cached.
17    #[inline]
18    pub(crate) unsafe fn from_ptr(handle: *mut ffi::VSFrameContext) -> Self {
19        Self {
20            handle: NonNull::new_unchecked(handle),
21            _owner: PhantomData,
22        }
23    }
24
25    /// Returns the underlying pointer.
26    #[inline]
27    pub(crate) fn ptr(self) -> *mut ffi::VSFrameContext {
28        self.handle.as_ptr()
29    }
30}