diff --git a/src/util/dictionary/mutable.rs b/src/util/dictionary/mutable.rs index 25ce2b0..7839daa 100644 --- a/src/util/dictionary/mutable.rs +++ b/src/util/dictionary/mutable.rs @@ -25,7 +25,7 @@ impl<'a> Ref<'a> { } impl<'a> Ref<'a> { - pub fn set(&mut self, key: &str, value: &str) { + pub fn set(&mut self, key: &str, value: &str) -> &mut Self { unsafe { let key = CString::new(key).unwrap(); let value = CString::new(value).unwrap(); @@ -38,6 +38,8 @@ impl<'a> Ref<'a> { self.ptr = ptr; self.imm = immutable::Ref::wrap(ptr); } + + self } } diff --git a/src/util/dictionary/owned.rs b/src/util/dictionary/owned.rs index d15eaa8..f2aed24 100644 --- a/src/util/dictionary/owned.rs +++ b/src/util/dictionary/owned.rs @@ -24,11 +24,11 @@ impl Owned { result } - pub fn as_ptr(&self) -> *const AVDictionary { + pub unsafe fn as_ptr(&self) -> *const AVDictionary { self.ptr } - pub fn as_mut_ptr(&mut self) -> *mut AVDictionary { + pub unsafe fn as_mut_ptr(&mut self) -> *mut AVDictionary { self.ptr } } @@ -47,6 +47,15 @@ impl Owned { pub fn as_mut(&self) -> mutable::Ref { unsafe { mutable::Ref::wrap(self.ptr) } } + + pub fn iter(&self) -> Iter<'_> { + unsafe { Iter::new(self.as_ptr()) } + } + + pub fn set(&mut self, key: &str, value: &str) -> &mut Self { + self.as_mut().set(key, value); + self + } } impl<'a> FromIterator<(&'a str, &'a str)> for Owned {