Skip to main content

ffmpeg_the_third/util/dictionary/
immutable.rs

1use std::fmt;
2use std::marker::PhantomData;
3
4use super::Iter;
5use crate::ffi::*;
6use crate::AsPtr;
7
8pub struct DictionaryRef<'d> {
9    ptr: *const AVDictionary,
10    _marker: PhantomData<&'d AVDictionary>,
11}
12
13impl<'d> DictionaryRef<'d> {
14    pub unsafe fn from_raw(ptr: *const AVDictionary) -> Self {
15        DictionaryRef {
16            ptr,
17            _marker: PhantomData,
18        }
19    }
20
21    pub fn as_ptr(&self) -> *const AVDictionary {
22        self.ptr
23    }
24}
25
26impl<'a> IntoIterator for &'a DictionaryRef<'a> {
27    type Item = (&'a str, &'a str);
28    type IntoIter = Iter<'a>;
29
30    fn into_iter(self) -> Self::IntoIter {
31        self.iter()
32    }
33}
34
35impl<'a> fmt::Debug for DictionaryRef<'a> {
36    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
37        f.debug_map().entries(self.iter()).finish()
38    }
39}
40
41impl<'d> AsPtr<AVDictionary> for DictionaryRef<'d> {
42    fn as_ptr(&self) -> *const AVDictionary {
43        self.ptr
44    }
45}