Skip to main content

ffmpeg_the_third/codec/subtitle/
rect.rs

1use std::marker::PhantomData;
2use std::ptr::NonNull;
3
4use super::Subtitle;
5use crate::ffi::*;
6use crate::AsPtr;
7
8pub struct RectRef<'s> {
9    ptr: NonNull<AVSubtitleRect>,
10    _marker: PhantomData<&'s Subtitle>,
11}
12
13impl<'s> RectRef<'s> {
14    /// # Safety
15    /// `ptr` must be a valid pointer to an [`AVSubtitleRect`].
16    /// Ensure that the returned lifetime is correctly bounded.
17    pub unsafe fn from_ptr(ptr: NonNull<AVSubtitleRect>) -> Self {
18        Self {
19            ptr,
20            _marker: PhantomData,
21        }
22    }
23}
24
25impl<'s> AsPtr<AVSubtitleRect> for RectRef<'s> {
26    fn as_ptr(&self) -> *const AVSubtitleRect {
27        self.ptr.as_ptr()
28    }
29}